success = tmpFile.createNewFile();
} catch (IOException e) {
}
if (!success) {
final String msg = CorePlugin.Util.getString("FileUtils.Unable_to_create_file_in", dirPath); //$NON-NLS-1$
throw new TeiidException(msg);
}
//test if file can be written to
if (!tmpFile.canWrite()) {
final String msg = CorePlugin.Util.getString("FileUtils.Unable_to_write_file_in", dirPath); //$NON-NLS-1$
throw new TeiidException(msg);
}
//test if file can be read
if (!tmpFile.canRead()) {
final String msg = CorePlugin.Util.getString("FileUtils.Unable_to_read_file_in", dirPath); //$NON-NLS-1$
throw new TeiidException(msg);
}
//test if file can be renamed
File newFile = new File(dirPath + File.separatorChar + TEMP_FILE_RENAMED);
success = false;
try {
success = tmpFile.renameTo(newFile);
} catch (Exception e) {
}
if (!success) {
final String msg = CorePlugin.Util.getString("FileUtils.Unable_to_rename_file_in", dirPath); //$NON-NLS-1$
throw new TeiidException(msg);
}
//test if file can be deleted
success = false;
try {
success = newFile.delete();
} catch (Exception e) {
}
if (!success) {
final String msg = CorePlugin.Util.getString("FileUtils.Unable_to_delete_file_in", dirPath); //$NON-NLS-1$
throw new TeiidException(msg);
}
}