public class SbFileHelper extends Inventor
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.
Modifier and Type | Class and Description |
---|---|
static class |
SbFileHelper.FileAccess
File access mode enum.
|
Inventor.ConstructorCommand
Modifier and Type | Field and Description |
---|---|
static int |
EXECUTE
Deprecated.
Use
SbFileHelper.FileAccess.EXECUTE instead. |
static int |
EXISTENCE
Deprecated.
Use
SbFileHelper.FileAccess.EXISTENCE instead. |
static int |
READ
Deprecated.
Use
SbFileHelper.FileAccess.READ instead. |
static int |
READ_WRITE
Deprecated.
Use
SbFileHelper.FileAccess.READ_WRITE instead. |
static int |
WRITE
Deprecated.
Use
SbFileHelper.FileAccess.WRITE instead. |
VERBOSE_LEVEL, ZeroHandle
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
cleanUpPath(java.lang.String path)
Removes all multiple occurences of '/' in the path.
|
static boolean |
containsWindowsDrive(java.lang.String path)
Returns true if the specified path starts with a Microsoft Windows drive letter.
|
static int |
createDirectory(java.lang.String directory)
Create the specified directory.
|
static java.lang.String |
expandString(java.lang.String string)
Returns a new version of the string with "$NAME" SoPreference variable names expanded to their defined value.
|
static java.lang.String |
fileSystemURLToFilename(java.lang.String url)
Converts a file system URL to a regular filename
E.g "file:///c:/temp/test.dat" becomes "c:/temp/test.dat". |
static java.lang.String |
getBaseName(java.lang.String fullFilePath)
Returns the filename part of a full path string.
|
static java.lang.String |
getCurrentDirectory()
Returns the current directory.
|
static java.lang.String |
getDirName(java.lang.String fullFilePath)
Returns the directory path part of a full path string.
|
static java.lang.String |
getExtension(java.lang.String filename)
Returns the extension part of the specified filename.
|
static java.lang.String |
getTempDirectory()
Returns the path to the temporary directory used by the system.
|
static java.lang.String |
getTempFilename(java.lang.String path,
java.lang.String prefix)
Returns a temporary filename.
|
static boolean |
isAccessible(java.lang.String filename)
Calls isAccessible(filename, SbFileHelper.FileAccess.valueOf( SbFileHelper.FileAccess.READ.getValue() )).
|
static boolean |
isAccessible(java.lang.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(java.lang.String filename)
Returns true if the filename is a file system URL like:
|
static boolean |
isUrl(java.lang.String filename)
Returns true if the filename is a network url like:
|
static java.lang.String |
makeFileSystemURL(java.lang.String filename)
Converts a filename to a file system URL.
|
static int |
removeFile(java.lang.String fileName)
Removes the specified file.
|
static int |
setCurrentDirectory(java.lang.String directory)
Sets the current working directory.
|
void |
setValue(SbFileHelper copyFrom) |
static java.lang.String |
toUnixPath(java.lang.String path)
Converts a Microsoft Windows path (with '\') to a Unix path (with '/').
|
static java.lang.String |
toWindowsPath(java.lang.String path)
Converts a Unix path (with '/') to a Microsoft Windows path (with '\').
|
dispose, getAddress, getNativeResourceHandle, startInternalThreads, stopInternalThreads
@Deprecated public static final int EXISTENCE
SbFileHelper.FileAccess.EXISTENCE
instead.@Deprecated public static final int WRITE
SbFileHelper.FileAccess.WRITE
instead.@Deprecated public static final int READ
SbFileHelper.FileAccess.READ
instead.@Deprecated public static final int READ_WRITE
SbFileHelper.FileAccess.READ_WRITE
instead.@Deprecated public static final int EXECUTE
SbFileHelper.FileAccess.EXECUTE
instead.public static boolean isAccessible(java.lang.String filename)
public static java.lang.String cleanUpPath(java.lang.String path)
public static java.lang.String expandString(java.lang.String string)
public void setValue(SbFileHelper copyFrom)
public static java.lang.String getTempFilename(java.lang.String path, java.lang.String prefix)
path
- The path to the directory which will contain the file (see getTempDirectory()
).
prefix
- The filename prefix.
public static boolean isAccessible(java.lang.String filename, SbFileHelper.FileAccess mode)
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.
filename
- The file to test.
mode
- The file access mode
public static int createDirectory(java.lang.String directory)
directory
- The path of the directory to create.
public static java.lang.String getBaseName(java.lang.String fullFilePath)
fullFilePath
- The full path string
public static java.lang.String getCurrentDirectory()
public static java.lang.String fileSystemURLToFilename(java.lang.String url)
url
- The URL to convert.
public static java.lang.String getTempDirectory()
getTempFilename()
method. The path ends with an operating system dependent directory separator.public static java.lang.String toWindowsPath(java.lang.String path)
path
- The path to convert.
public static java.lang.String getDirName(java.lang.String fullFilePath)
fullFilePath
- The full path string
public static java.lang.String toUnixPath(java.lang.String path)
path
- The path to convert.
public static int removeFile(java.lang.String fileName)
fileName
- The file to remove.
public static boolean isUrl(java.lang.String filename)
public static java.lang.String getExtension(java.lang.String 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".
public static int setCurrentDirectory(java.lang.String directory)
public static java.lang.String makeFileSystemURL(java.lang.String filename)
Actually it just adds the string
filename
- The file name to convert
public static boolean containsWindowsDrive(java.lang.String path)
public static boolean isFileSystemUrl(java.lang.String filename)
Generated on January 23, 2025, Copyright © Thermo Fisher Scientific. All rights reserved. http://www.openinventor.com