public class DefaultFileAccess extends Object implements FileAccess
FileAccess
interface.
This is used if the SetUID version is not available.DEFAULT_BUFFERSIZE
Constructor and Description |
---|
DefaultFileAccess() |
Modifier and Type | Method and Description |
---|---|
void |
asUser(Runnable runnable,
String user,
String group)
execute the given Runnable as given user
|
String |
getHome(String userID)
gets the user's home directory
|
RandomAccessFile |
getRandomAccessFile(File file,
String userID,
String groupID,
String mode)
create a
RandomAccessFile for accessing the given path |
FileInfo[] |
listFiles(File dir,
String userID,
String groupID)
lists files in the given directory
|
void |
mkdir(String canonicalPath,
String user,
String group)
create a directory.
|
InputStream |
readFile(String canonicalPath,
String userID,
String groupID,
int size)
create a
InputStream for reading |
void |
rm(String canonicalPath,
String user,
String group)
delete a file or directory
|
void |
setUser(String canonicalPath,
String user,
String group)
set user/group on the given file
|
FileInfo |
stat(String path,
String userID,
String groupID)
get info on a single file
|
OutputStream |
writeFile(String canonicalPath,
boolean append,
String userID,
String groupID,
int size)
create a
OutputStream for writing |
public InputStream readFile(String canonicalPath, String userID, String groupID, int size) throws Exception
FileAccess
InputStream
for readingreadFile
in interface FileAccess
canonicalPath
- - the canonical path to the fileuserID
- - the user idgroupID
- - the group idsize
- - the buffer size for reading fromInputStream
Exception
public void setUser(String canonicalPath, String user, String group) throws Exception
FileAccess
setUser
in interface FileAccess
Exception
public OutputStream writeFile(String canonicalPath, boolean append, String userID, String groupID, int size) throws Exception
FileAccess
OutputStream
for writingwriteFile
in interface FileAccess
canonicalPath
- - the canonical path to the fileuserID
- - the user idgroupID
- - the group idsize
- - the buffer size for writing to diskOutputStream
Exception
public RandomAccessFile getRandomAccessFile(File file, String userID, String groupID, String mode) throws IOException
FileAccess
RandomAccessFile
for accessing the given pathgetRandomAccessFile
in interface FileAccess
file
- - the pathuserID
- - the user idgroupID
- - the group idmode
- - the mode (see RandomAccessFile.RandomAccessFile(java.io.File, String)
IOException
public void mkdir(String canonicalPath, String user, String group) throws Exception
FileAccess
mkdir
in interface FileAccess
canonicalPath
- - the directory to createuser
- - user IDgroup
- - group IPException
public void rm(String canonicalPath, String user, String group) throws Exception
FileAccess
rm
in interface FileAccess
canonicalPath
- - the file/directory to deleteuser
- - user IDgroup
- - group IPException
public FileInfo[] listFiles(File dir, String userID, String groupID)
FileAccess
listFiles
in interface FileAccess
userID
- - the user idgroupID
- - the group idFileInfo
objectspublic FileInfo stat(String path, String userID, String groupID)
FileAccess
stat
in interface FileAccess
path
- - the fileuserID
- - the user idgroupID
- - the group idpublic String getHome(String userID)
FileAccess
getHome
in interface FileAccess
public void asUser(Runnable runnable, String user, String group) throws Exception
FileAccess
asUser
in interface FileAccess
runnable
- - a very SHORT taskuser
- - user IDgroup
- - group IDException
Copyright © 2010–2016 UNICORE. All rights reserved.