Class SbFileHelper
File path strings can contain SoPreference (environment) variable names preceded by the '$' (dollar sign) character. These names are expanded to their defined value before passing the string to the operating system. For example, "$OIVHOME/data/models/bird.iv" could be used to access a file installed by the Open Inventor SDK. If the specified name does not have a defined value, the name is used as-is.
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class com.openinventor.inventor.Inventor
Inventor.ConstructorCommand
-
Field Summary
Fields inherited from class com.openinventor.inventor.Inventor
VERBOSE_LEVEL, ZeroHandle
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
cleanUpPath
(String path) Removes all multiple occurences of '/' in the path.static boolean
containsWindowsDrive
(String path) Returns true if the specified path starts with a Microsoft Windows drive letter.static int
createDirectory
(String directory) Create the specified directory.static String
expandString
(String string) Returns a new version of the string with "$NAME" SoPreference variable names expanded to their defined value.static String
Converts a file system URL to a regular filename
E.g "file:///c:/temp/test.dat" becomes "c:/temp/test.dat".static String
getBaseName
(String fullFilePath) Returns the filename part of a full path string.static String
Returns the current directory.static String
getDirName
(String fullFilePath) Returns the directory path part of a full path string.static String
getExtension
(String filename) Returns the extension part of the specified filename.static String
Returns the path to the temporary directory used by the system.static String
getTempFilename
(String path, String prefix) Returns a temporary filename.static boolean
isAccessible
(String filename) Calls isAccessible(filename, SbFileHelper.FileAccess.valueOf( SbFileHelper.FileAccess.READ.getValue() )).static boolean
isAccessible
(String filename, SbFileHelper.FileAccess mode) Returns true if a file is accessible
The default value of the mode parameter is READ_ONLY.static boolean
isFileSystemUrl
(String filename) Returns true if the filename is a file system URL like: file://...static boolean
static String
makeFileSystemURL
(String filename) Converts a filename to a file system URL.static int
removeFile
(String fileName) Removes the specified file.static int
setCurrentDirectory
(String directory) Sets the current working directory.void
setValue
(SbFileHelper copyFrom) static String
toUnixPath
(String path) Converts a Microsoft Windows path (with '\') to a Unix path (with '/').static String
toWindowsPath
(String path) Converts a Unix path (with '/') to a Microsoft Windows path (with '\').Methods inherited from class com.openinventor.inventor.Inventor
dispose, getNativeResourceHandle
-
Method Details
-
isAccessible
Calls isAccessible(filename, SbFileHelper.FileAccess.valueOf( SbFileHelper.FileAccess.READ.getValue() )). -
cleanUpPath
Removes all multiple occurences of '/' in the path. -
expandString
Returns a new version of the string with "$NAME" SoPreference variable names expanded to their defined value. If the specified name does not have a defined value, the name is copied as-is. -
setValue
-
getTempFilename
Returns a temporary filename.- Parameters:
path
- The path to the directory which will contain the file (seegetTempDirectory()
).prefix
- The filename prefix.- Returns:
- A temporary filename.
-
isAccessible
Returns true if a file is accessible
The default value of the mode parameter is READ_ONLY.Note that this method cannot be used to test if it is possible to create a file for writing. It only works on existing files.
- Parameters:
filename
- The file to test.mode
- The file access mode- Returns:
- true if the file is accessible, false otherwise.
-
createDirectory
Create the specified directory.- Parameters:
directory
- The path of the directory to create.- Returns:
- -1 if creation failed.
-
getBaseName
Returns the filename part of a full path string.
E.g If the full path is "/tmp/a.tmp", the function will return "a.tmp"- Parameters:
fullFilePath
- The full path string- Returns:
- The extracted filename
-
getCurrentDirectory
Returns the current directory. -
fileSystemURLToFilename
Converts a file system URL to a regular filename
E.g "file:///c:/temp/test.dat" becomes "c:/temp/test.dat".- Parameters:
url
- The URL to convert.- Returns:
- The converted filename.
-
getTempDirectory
Returns the path to the temporary directory used by the system. Useful with thegetTempFilename()
method. The path ends with an operating system dependent directory separator. -
toWindowsPath
Converts a Unix path (with '/') to a Microsoft Windows path (with '\').- Parameters:
path
- The path to convert.- Returns:
- The converted path
-
getDirName
Returns the directory path part of a full path string.
E.g. If the full path is "/tmp/a.tmp", returns "/tmp/"- Parameters:
fullFilePath
- The full path string- Returns:
- The directory path string
-
toUnixPath
Converts a Microsoft Windows path (with '\') to a Unix path (with '/').
A leading "\\" (used for network paths) is not converted.- Parameters:
path
- The path to convert.- Returns:
- The converted path
-
removeFile
Removes the specified file.- Parameters:
fileName
- The file to remove.- Returns:
- An error code, 0 if there was no error.
-
isUrl
-
getExtension
Returns the extension part of the specified filename.
It does not include the '.' used to separate the file name and the extension!
E.g. If the filename is "test.dat", the function returns "dat". -
setCurrentDirectory
Sets the current working directory. Returns 0 if successful, else one of the POSIX "chdir" error codes. -
makeFileSystemURL
Converts a filename to a file system URL.
Actually it just adds the string file:// to the filename, if and only if the filename is not already a file system URL.
- Parameters:
filename
- The file name to convert- Returns:
- The converted filename.
-
containsWindowsDrive
Returns true if the specified path starts with a Microsoft Windows drive letter. -
isFileSystemUrl
Returns true if the filename is a file system URL like: file://...
-