зеркало из https://github.com/mozilla/pluotsorbet.git
make TestFileConnection assertions pass
This commit is contained in:
Родитель
b06cce78c9
Коммит
53e55233ec
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -633,6 +633,10 @@ var fs = (function() {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (size >= record.size) {
|
||||
return true;
|
||||
}
|
||||
|
||||
record.data = record.data.slice(0, size || 0, record.data.type);
|
||||
record.mtime = Date.now();
|
||||
record.size = size;
|
||||
|
|
25
midp/fs.js
25
midp/fs.js
|
@ -642,8 +642,9 @@ Native["javax/microedition/io/file/FileSystemRegistry.getRootsImpl.()[Ljava/lang
|
|||
|
||||
addUnimplementedNative("com/sun/cdc/io/j2me/file/DefaultFileHandler.initialize.()V");
|
||||
|
||||
// XXX Return characters in isValidFilenameImpl.
|
||||
addUnimplementedNative("com/sun/cdc/io/j2me/file/DefaultFileHandler.illegalFileNameChars0.()Ljava/lang/String;", null);
|
||||
Native["com/sun/cdc/io/j2me/file/DefaultFileHandler.illegalFileNameChars0.()Ljava/lang/String;"] = function() {
|
||||
return J2ME.newString('<>:"\\|?');
|
||||
};
|
||||
|
||||
Native["com/sun/cdc/io/j2me/file/DefaultFileHandler.getFileSeparator.()C"] = function() {
|
||||
return "/".charCodeAt(0);
|
||||
|
@ -897,5 +898,25 @@ Native["com/sun/cdc/io/j2me/file/DefaultFileHandler.lastModified.()J"] = functio
|
|||
Native["com/sun/cdc/io/j2me/file/DefaultFileHandler.truncate.(J)V"] = function(byteOffset) {
|
||||
var pathname = MIDP.nativeFilePointerToName.get(this.$fileName.toNumber());
|
||||
console.log("DefaultFileHandler.lastModified: " + pathname);
|
||||
|
||||
// XXX If the file is open, flush it first.
|
||||
|
||||
fs.truncate(pathname, byteOffset.toNumber());
|
||||
};
|
||||
|
||||
Native["com/sun/cdc/io/j2me/file/Protocol.available.()I"] = function() {
|
||||
var pathname = MIDP.nativeFilePointerToName.get(this.$fileHandler.$fileName.toNumber());
|
||||
var fd = MIDP.openFiles.get(this.$fileHandler.$fileName);
|
||||
var available = fs.getsize(fd) - fs.getpos(fd);
|
||||
console.log("Protocol.available: " + pathname + ": " + available);
|
||||
return available;
|
||||
};
|
||||
|
||||
Native["com/sun/cdc/io/j2me/file/DefaultFileHandler.rename0.(Ljava/lang/String;)V"] = function(newName) {
|
||||
var pathname = MIDP.nativeFilePointerToName.get(this.$fileName.toNumber());
|
||||
console.log("DefaultFileHandler.rename0: " + pathname);
|
||||
console.log("newName: " + util.fromJavaString(newName));
|
||||
if (!fs.rename(pathname, util.fromJavaString(newName))) {
|
||||
throw $.newIOException("Rename failed");
|
||||
}
|
||||
};
|
||||
|
|
|
@ -435,8 +435,9 @@ public class TestFileConnection implements Testlet {
|
|||
// }
|
||||
// out.close();
|
||||
|
||||
// Renaming after closing the file should succeed.
|
||||
|
||||
// Renaming before closing the file should succeed.
|
||||
file = (FileConnection)Connector.open(dirPath + "provaDir/nonexistent.txt");
|
||||
file.create();
|
||||
file.rename("newname");
|
||||
file.close();
|
||||
|
||||
|
@ -495,8 +496,8 @@ public class TestFileConnection implements Testlet {
|
|||
try {
|
||||
file = (FileConnection)Connector.open(dirPath + "prov>");
|
||||
th.fail("Exception expected");
|
||||
} catch (IllegalArgumentException e) {
|
||||
th.check(e.getMessage(), "Invalid file name in FileConnection Url: ///Private/prov>");
|
||||
} catch (IOException e) {
|
||||
th.check(e.getMessage(), "Contains characters invalid for a filename");
|
||||
}
|
||||
|
||||
// Check that the fileconn.dir.photos property value is longer than 8 characters.
|
||||
|
|
Загрузка…
Ссылка в новой задаче