* @param name the name of the file
* @param mode a raw io file mode String
*/
public FileIO(PyString name, String mode) {
parseMode(mode);
File absPath = new RelativeFile(name.toString());
try {
if (appending && !(reading || plus)) {
// Take advantage of FileOutputStream's append mode
fromFileOutputStream(absPath);
} else {
fromRandomAccessFile(absPath);
emulateAppend = appending;
}
} catch (FileNotFoundException fnfe) {
if (absPath.isDirectory()) {
throw Py.IOError(Errno.EISDIR, name);
}
if ((writing && !absPath.canWrite())
|| fnfe.getMessage().endsWith("(Permission denied)")) {
throw Py.IOError(Errno.EACCES, name);
}
throw Py.IOError(Errno.ENOENT, name);
}