Methods Summary |
---|
public static java.lang.String | asciiFilenameToUnicode(java.lang.String str)Perform the reverse conversion of unicodeToAscii().
StringBuffer sbuf = new StringBuffer();
for (int i = 0; i < str.length(); i++) {
char c = str.charAt(i);
if (c == '%") {
int v = 0;
v <<= 4; v += hexValue(str.charAt(i+1));
v <<= 4; v += hexValue(str.charAt(i+2));
v <<= 4; v += hexValue(str.charAt(i+3));
v <<= 4; v += hexValue(str.charAt(i+4));
i += 4;
sbuf.append((char)(v & 0x0000ffff));
} else if (c == '#") {
// drop c
} else {
sbuf.append(c);
}
}
return sbuf.toString();
|
private static native int | availableStorage()Gets the approximate number of free storage bytes remaining.
|
public synchronized void | delete(java.lang.String name)Remove a file from storage if it exists.
byte[] asciiFilename = Util.toCString(name);
deleteStorage(asciiFilename);
|
private static native void | deleteStorage(byte[] szFilename)Removes storage file szFilename.
|
public synchronized boolean | exists(java.lang.String name)Returns true if storage file name
exists.
byte[] asciiFilename = Util.toCString(name);
return storageExists(asciiFilename);
|
public synchronized java.util.Vector | filenamesThatStartWith(java.lang.String root)Finds the file names which start with prifix
root .
Vector list = new Vector();
byte[] szRoot;
String filename;
szRoot = Util.toCString(root);
filename = getFirstFileThatStartsWith(szRoot);
while (filename != null) {
list.addElement(filename);
filename = getNextFileThatStartsWith(szRoot);
}
return list;
|
public int | getBytesAvailableForFiles()Retrieves the approximate space available to grow or
create new storage files.
return availableStorage();
|
private static native java.lang.String | getFirstFileThatStartsWith(byte[] szRoot)The calling method should be synchronzed and call
getNextFileThatStartsWith until it returns null since
they share static state information.
|
private static native java.lang.String | getNextFileThatStartsWith(byte[] szRoot)getFirstFileThatStartsWith must becalled first since it sets up
some shared static state.
|
public static java.lang.String | getStorageRoot()Returns the root to build storage filenames including an needed
file separators, abstracting difference of the file systems
of development and device platforms. Note the root is never null.
if (storageRoot == null) {
storageRoot = initStorageRoot();
}
return storageRoot;
|
private static int | hexValue(char c)A utility method that convert a hex character 0-9a-f to the
numerical value represented by this hex char.
if (c >= '0" && c <= '9") {
return ((int)c) - '0";
} else {
return ((int)c) - 'a" + 10;
}
|
private static native java.lang.String | initStorageRoot()Initializes storage root for this file instance.
|
public synchronized void | rename(java.lang.String oldName, java.lang.String newName)Replaces the current name of storage, oldName
with newName .
byte[] oldAsciiFilename = Util.toCString(oldName);
byte[] newAsciiFilename = Util.toCString(newName);
renameStorage(oldAsciiFilename, newAsciiFilename);
|
private static native void | renameStorage(byte[] szOldName, byte[] szNewName)Renames storage file.
|
private static native boolean | storageExists(byte[] szFilename)Determines if a storage file matching szFilename exists.
|
public static java.lang.String | unicodeToAsciiFilename(java.lang.String str)Convert a file name into a form that can be safely stored on
an ANSI-compatible file system. All characters that are not
[A-Za-z0-9] are converted into %uuuu, where uuuu is the hex
representation of the character's unicode value. Note even
though "_" is allowed it is converted because we use it for
for internal purposes. Potential file separators are converted
so the native layer does not have deal with sub-directory hierachies.
StringBuffer sbuf = new StringBuffer();
for (int i = 0; i < str.length(); i++) {
char c = str.charAt(i);
if ((c >= 'a" && c <= 'z") ||
(c >= '0" && c <= '9")) {
sbuf.append(c);
} else if (c >= 'A" && c <= 'Z") {
sbuf.append('#");
sbuf.append(c);
} else {
int v = (int)(c & 0xffff);
sbuf.append('%");
sbuf.append(NUMS[(v & 0xf000) >> 12]);
sbuf.append(NUMS[(v & 0x0f00) >> 8]);
sbuf.append(NUMS[(v & 0x00f0) >> 4]);
sbuf.append(NUMS[(v & 0x000f) >> 0]);
}
}
return sbuf.toString();
|