This commit is contained in:
Marco Castelluccio 2014-11-14 02:05:13 +01:00
Родитель 8fd26d437a b89dea47bd
Коммит 68e1265c32
4 изменённых файлов: 51 добавлений и 30 удалений

Просмотреть файл

@ -10,8 +10,8 @@ VPATH=./cldc1.1.1 ./vm ./midp ./custom
classes.jar: $(SRCS) $(CUSTOM_SRCS) $(JPP_DESTS)
rm -rf build
mkdir build
javac -cp cldc1.1.1:vm:midp -source 1.3 -target 1.3 -d ./build $(SRCS) > /dev/null
javac -sourcepath custom -cp build -source 1.3 -target 1.3 -d ./build $(CUSTOM_SRCS) > /dev/null
javac -cp cldc1.1.1:vm:midp -source 1.3 -target 1.3 -bootclasspath "" -extdirs "" -d ./build $(SRCS) > /dev/null
javac -sourcepath custom -cp build -source 1.3 -target 1.3 -bootclasspath "" -extdirs "" -d ./build $(CUSTOM_SRCS) > /dev/null
cd build && jar cvf0 ../classes.jar *
jar uvf0 classes.jar $(EXTRA)
rm -rf build

Просмотреть файл

@ -88,6 +88,7 @@ var fs = (function() {
}
var openedFiles = [];
var fileStats = {};
function open(path, cb) {
path = normalizePath(path);
@ -168,9 +169,11 @@ var fs = (function() {
buffer.array.set(data, from);
openedFiles[fd].position = from + data.byteLength;
openedFiles[fd].stat = { mtime: Date.now(), isDir: false };
openedFiles[fd].dirty = true;
var file = openedFiles[fd];
file.position = from + data.byteLength;
file.stat = { mtime: Date.now(), isDir: false, size: buffer.contentSize };
file.dirty = true;
fileStats[file.path] = file.stat;
}
function getpos(fd) {
@ -233,7 +236,7 @@ var fs = (function() {
stat(path, function(stat) {
if (stat && !stat.isDir) {
asyncStorage.setItem(path, new Blob(), function() {
setStat(path, { mtime: Date.now(), isDir: false });
setStat(path, { mtime: Date.now(), isDir: false, size: 0 });
cb(true);
});
} else {
@ -243,10 +246,11 @@ var fs = (function() {
}
function ftruncate(fd, size) {
if (size != openedFiles[fd].buffer.contentSize) {
openedFiles[fd].buffer.setSize(size);
openedFiles[fd].stat = { mtime: Date.now(), isDir: false };
openedFiles[fd].dirty = true;
var file = openedFiles[fd];
if (size != file.buffer.contentSize) {
file.buffer.setSize(size);
file.dirty = true;
fileStats[file.path] = file.stat = { mtime: Date.now(), isDir: false, size: size };
}
}
@ -311,7 +315,7 @@ var fs = (function() {
createInternal(path, blob, function(created) {
if (created) {
setStat(path, { mtime: Date.now(), isDir: false }, function() {
setStat(path, { mtime: Date.now(), isDir: false, size: blob.size }, function() {
cb(created);
});
} else {
@ -379,10 +383,18 @@ var fs = (function() {
function size(path, cb) {
path = normalizePath(path);
if (fileStats[path] && typeof fileStats[path].size != "undefined") {
cb(fileStats[path].size);
return;
}
asyncStorage.getItem(path, function(blob) {
if (blob == null || !(blob instanceof Blob)) {
cb(-1);
} else {
if (fileStats[path]) {
fileStats[path].size = blob.size;
}
cb(blob.size);
}
});
@ -428,23 +440,36 @@ var fs = (function() {
}
function setStat(path, stat, cb) {
fileStats[path] = stat;
asyncStorage.setItem("!" + path, stat, cb);
}
function removeStat(path, cb) {
delete fileStats[path];
asyncStorage.removeItem("!" + path, cb);
}
function stat(path, cb) {
path = normalizePath(path);
var stat = fileStats[path];
if (stat) {
setTimeout(() => cb(stat), 0);
return;
}
var file = openedFiles.find(file => file && file.stat && file.path === path);
if (file) {
setTimeout(() => cb(file.stat), 0);
return;
}
asyncStorage.getItem("!" + path, cb);
asyncStorage.getItem("!" + path, function(stat) {
if (stat) {
fileStats[path] = stat;
}
cb(stat);
});
}
return {

Просмотреть файл

@ -32,9 +32,9 @@ tests.jar: $(SRCS) Testlets.java
rm -rf build
mkdir build
# Build the buildtime support classes in-place, not in ./build, so they aren't available at runtime.
javac -source 1.3 -target 1.3 -encoding UTF-8 -bootclasspath ../java/classes.jar $(BUILDTIME_SUPPORT_SRCS) > /dev/null
javac -source 1.3 -target 1.3 -encoding UTF-8 -bootclasspath ../java/classes.jar:$(BUILDTIME_SUPPORT_DIR) -d ./build $^ > /dev/null
javac -source 1.3 -target 1.3 -encoding UTF-8 -bootclasspath ../java/classes.jar -d ./build $(RUNTIME_SUPPORT_SRCS) > /dev/null
javac -source 1.3 -target 1.3 -encoding UTF-8 -bootclasspath ../java/classes.jar -extdirs "" $(BUILDTIME_SUPPORT_SRCS) > /dev/null
javac -source 1.3 -target 1.3 -encoding UTF-8 -bootclasspath ../java/classes.jar:$(BUILDTIME_SUPPORT_DIR) -extdirs "" -d ./build $^ > /dev/null
javac -source 1.3 -target 1.3 -encoding UTF-8 -bootclasspath ../java/classes.jar -extdirs "" -d ./build $(RUNTIME_SUPPORT_SRCS) > /dev/null
jar cvfe tests.jar RunTests -C build/ .
jar uvf $(PACKAGE_FILES) > /dev/null
rm -rf build

Просмотреть файл

@ -65,18 +65,15 @@ tests.push(function() {
});
tests.push(function() {
fs.close(-1);
next();
fs.close(-1, next);
});
tests.push(function() {
fs.close(0);
next();
fs.close(0, next);
});
tests.push(function() {
fs.close(1);
next();
fs.close(1, next);
});
tests.push(function() {
@ -332,8 +329,7 @@ tests.push(function() {
});
tests.push(function() {
fs.close(0);
next();
fs.close(0, next);
});
tests.push(function() {
@ -495,7 +491,7 @@ tests.push(function() {
tests.push(function() {
fs.size("/tmp/tmp.txt", function(size) {
is(size, 0, "unflushed file's size is 0");
is(size, 12, "unflushed file's size is 12");
next();
});
});
@ -550,8 +546,7 @@ tests.push(function() {
});
tests.push(function() {
fs.close(1);
next();
fs.close(1, next);
});
tests.push(function() {
@ -760,10 +755,11 @@ tests.push(function() {
tests.push(function() {
window.setTimeout(function() {
fs.flush(fd, function() {
fs.close(fd);
fs.stat("/tmp/stat.txt", function(stat) {
is(stat.mtime, lastTime, "close doesn't update mtime");
next();
fs.close(fd, function() {
fs.stat("/tmp/stat.txt", function(stat) {
is(stat.mtime, lastTime, "close doesn't update mtime");
next();
});
});
});
}, 1);