Class SqlJetFileSystem
- java.lang.Object
-
- org.tmatesoft.sqljet.core.internal.fs.SqlJetFileSystem
-
- All Implemented Interfaces:
ISqlJetFileSystem
public class SqlJetFileSystem extends java.lang.Object implements ISqlJetFileSystem
Default implementation of ISqlJetFileSystem.- Author:
- TMate Software Ltd., Sergey Scherbina (sergey.scherbina@gmail.com)
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
FS_NAME
-
Constructor Summary
Constructors Constructor Description SqlJetFileSystem()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
access(java.io.File path, SqlJetFileAccesPermission permission)
The flags argument to access() may beSqlJetFileAccesPermission.EXISTS
to test for the existence of a file, orSqlJetFileAccesPermission.READWRITE
to test whether a file is readable and writable, orSqlJetFileAccesPermission#READ
to test whether a file is at least readable.long
currentTime()
The currentTime() method returns a Julian Day Number for the current date and time.boolean
delete(java.io.File path, boolean sync)
Delete the file.java.lang.String
getFullPath(java.io.File filename)
java.lang.String
getName()
The getName() returns the name of the FS module.java.io.File
getTempFile()
ISqlJetFile
memJournalOpen()
Open a memory journal file.ISqlJetFile
open(java.io.File path, SqlJetFileType type, java.util.Set<SqlJetFileOpenPermission> permissions)
The flags argument to open() includes all set in the flags argument to ISqlJet.open().byte[]
randomness(int numBytes)
The randomness() function returns numBytes bytes of good-quality randomness.long
sleep(long microseconds)
The sleep() method causes the calling thread to sleep for at least the number of microseconds given.
-
-
-
Method Detail
-
getName
public java.lang.String getName()
Description copied from interface:ISqlJetFileSystem
The getName() returns the name of the FS module. The name must be unique across all FS modules.- Specified by:
getName
in interfaceISqlJetFileSystem
- Returns:
-
open
public ISqlJetFile open(java.io.File path, SqlJetFileType type, java.util.Set<SqlJetFileOpenPermission> permissions) throws SqlJetException
Description copied from interface:ISqlJetFileSystem
The flags argument to open() includes all set in the flags argument to ISqlJet.open(). Flags includes at leastSqlJetFileOpenPermission.READWRITE
andSqlJetFileOpenPermission.CREATE
. If open() opens a file read-only then it sets flags inISqlJetFile.getPermissions()
to includeSqlJetFileOpenPermission.READONLY
. Other permissions may be set. SqlJet will also add one of the following flags to the open() call, depending on the object being opened:-
SqlJetFileOpenPermission#MAIN_DB
-
SqlJetFileOpenPermission#MAIN_JOURNAL
-
SqlJetFileOpenPermission#TEMP_DB
-
SqlJetFileOpenPermission#TEMP_JOURNAL
-
SqlJetFileOpenPermission#TRANSIENT_DB
-
SqlJetFileOpenPermission#SUBJOURNAL
-
SqlJetFileOpenPermission#MASTER_JOURNAL
SqlJetIOException
. Or the implementation might recognize that a database file will be doing page-aligned sector reads and writes in a random order and set up its I/O subsystem accordingly. SqlJet might also add one of the following flags to the open() method: TheSqlJetFileOpenPermission.DELETEONCLOSE
flag means the file should be deleted when it is closed. TheSqlJetFileOpenPermission.DELETEONCLOSE
will be set for TEMP databases, journals and for subjournals. TheSqlJetFileOpenPermission.EXCLUSIVE
flag means the file should be opened for exclusive access. This flag is set for all files except for the main database file.- Specified by:
open
in interfaceISqlJetFileSystem
- Parameters:
path
-File
or NULL. If NULL then open() must invite its own temporary name for the file. Whenever the filename parameter is NULL it will also be the case that the flags parameter will includeSqlJetFileOpenPermission.DELETEONCLOSE
.permissions
- Exactly one of theSqlJetFileOpenPermission.READWRITE
andSqlJetFileOpenPermission.READONLY
flags must be set, and ifSqlJetFileOpenPermission.CREATE
is set, thenSqlJetFileOpenPermission.READWRITE
must also be set, and ifSqlJetFileOpenPermission.EXCLUSIVE
is set, thenSqlJetFileOpenPermission.CREATE
must also be set. ifSqlJetFileOpenPermission.DELETEONCLOSE
is set, thenSqlJetFileOpenPermission.CREATE
must also be set.- Returns:
- Opened file.
- Throws:
SqlJetException
- If it is impossible to open file.
-
-
getTempFile
public java.io.File getTempFile() throws java.io.IOException
- Specified by:
getTempFile
in interfaceISqlJetFileSystem
- Returns:
- Throws:
java.io.IOException
-
delete
public boolean delete(java.io.File path, boolean sync)
Description copied from interface:ISqlJetFileSystem
Delete the file. If the sync argument is true, sync() the directory after deleting the file.- Specified by:
delete
in interfaceISqlJetFileSystem
- Returns:
-
access
public boolean access(java.io.File path, SqlJetFileAccesPermission permission) throws SqlJetException
Description copied from interface:ISqlJetFileSystem
The flags argument to access() may beSqlJetFileAccesPermission.EXISTS
to test for the existence of a file, orSqlJetFileAccesPermission.READWRITE
to test whether a file is readable and writable, orSqlJetFileAccesPermission#READ
to test whether a file is at least readable. The file can be a directory. Test the existance of or access permissions of file. The test performed depends on the value of flags:SqlJetFileAccesPermission.EXISTS
: Return true if the file existsSqlJetFileAccesPermission.READWRITE
: Return true if the file is read and writable.SqlJetFileAccesPermission#READ
: Return true if the file is readable. Otherwise return false.- Specified by:
access
in interfaceISqlJetFileSystem
- Returns:
- Throws:
SqlJetException
-
currentTime
public long currentTime()
Description copied from interface:ISqlJetFileSystem
The currentTime() method returns a Julian Day Number for the current date and time.- Specified by:
currentTime
in interfaceISqlJetFileSystem
- Returns:
-
randomness
public byte[] randomness(int numBytes)
Description copied from interface:ISqlJetFileSystem
The randomness() function returns numBytes bytes of good-quality randomness.- Specified by:
randomness
in interfaceISqlJetFileSystem
- Returns:
-
sleep
public long sleep(long microseconds)
Description copied from interface:ISqlJetFileSystem
The sleep() method causes the calling thread to sleep for at least the number of microseconds given.- Specified by:
sleep
in interfaceISqlJetFileSystem
- Returns:
-
memJournalOpen
public ISqlJetFile memJournalOpen()
Description copied from interface:ISqlJetFileSystem
Open a memory journal file.- Specified by:
memJournalOpen
in interfaceISqlJetFileSystem
-
getFullPath
public java.lang.String getFullPath(java.io.File filename) throws SqlJetException
- Specified by:
getFullPath
in interfaceISqlJetFileSystem
- Throws:
SqlJetException
-
-