The VCSSL File library is a standard library that provides various file-related functions, such as obtaining file paths and getting lists of file names in directories.
However, this library does not handle file I/O. For file I/O, use the System library or the file.TextFile library.
- None -
| Name | ABSOLUTE |
| Declaration | const int ABSOLUTE |
| Description | The option value representing an absolute path. |
| Name | RELATIVE |
| Declaration | const int RELATIVE |
| Description | The option value representing a relative path. |
| Name | PARENT |
| Declaration | const int PARENT |
| Description | The option value representing a parent directory. |
| Name | HOME |
| Declaration | const int HOME |
| Description | The option value representing the user's home directory. |
| Name | ROOT |
| Declaration | const int ROOT |
| Description | The option value representing the root directory. |
| Name | TMP |
| Declaration | const int TMP |
| Description | The option value representing the temporary-file directory provided by the computer. |
| Name | UNORDERED |
| Declaration | const int UNORDERED |
| Description | The option value representing an unordered file order. |
| Name | LEXICAL |
| Declaration | const int LEXICAL |
| Description | The option value representing a lexically sorted file order. |
| Name | isDirectory |
| Declaration | bool isDirectory( string pathOrName ) |
| Description | Determines whether the specified file is a directory. |
| Parameters | (string type) pathOrName : The name or path of the target file. |
| Return | (bool type) Returns true if it is a directory, otherwise false. |
| Name | makeDirectory |
| Declaration | void makeDirectory( string pathOrName ) |
| Description | Creates a new directory. |
| Parameters | (string type) pathOrName : The name or path of the directory to create. |
| Return | (void type) |
| Name | listDirectory |
| Declaration | string[ ] listDirectory( string pathOrName ) |
| Description | Returns the list of file names directly under the specified directory. The order of file names is not specifically sorted and depends on the environment and implementation. |
| Parameters | (string type) pathOrName : The name or path of the target directory. |
| Return | (string[] type) The list of file names directly under the directory. |
| Name | listDirectory |
| Declaration | string[ ] listDirectory( string pathOrName, bool sortByIgnoreCase, int sortOption ) |
| Description | Returns the list of file names directly under the specified directory. A sorting option for file names can be specified. |
| Parameters |
(string type) pathOrName : The name or path of the target directory. (bool type) sortByIgnoreCase : Whether case should be distinguished when sorting. If true, case differences are ignored. (int type) sortOption : The sorting option. Specify UNORDERED or LEXICAL. |
| Return | (string[] type) The list of file names directly under the directory. |
| Name | makeFile |
| Declaration | void makeFile( string pathOrName ) |
| Description | Creates a new file. |
| Parameters | (string type) pathOrName : The name or path of the file to create. |
| Return | (void type) |
| Name | getFileName |
| Declaration | string getFileName( string path ) |
| Description | Gets the file-name part from a file path. |
| Parameters | (string type) path : The path of the target file. |
| Return | (string type) The file name. |
| Name | removeFile |
| Declaration | void removeFile( string pathOrName ) |
| Description |
Deletes a file. If the target is a directory, it cannot be deleted unless it is empty, so its contents must be removed first. |
| Parameters | (string type) pathOrName : The name or path of the target file. |
| Return | (void type) |
| Name | moveFile |
| Declaration | void moveFile( string pathOrName, string newName ) |
| Description |
Moves a file or changes its file name. If both arguments are only file names, or if both are file paths in the same directory, the operation becomes a file rename.If the arguments are file paths in different directories, the operation becomes a file move.Moving across drives may not be supported depending on the environment. |
| Parameters |
(string type) pathOrName : The name or path of the target file. (string type) newName : The new name or destination path. |
| Return | (void type) |
| Name | renameFile |
| Declaration | void renameFile( string pathOrName, string newName ) |
| Description |
Renames a file. If a path is specified instead of just a file name as the destination,the file is moved. However, moving across drives may not be supported depending on the environment. Note: The use of this API is not recommended. Its behavior depends on the implementation and version. In VCSSL 3.3 and later, use moveFile instead.If you must use this API and want to avoid such dependencies, specify the destination file path newPath as an absolute path. The behavior when specifying only a relative path or file name depends on the implementation and version.In the current standard VCSSL runtime, if a file name or relative path is specified for newPath, it is interpreted relative to the location of the executed program. However, in older versions such as VCSSL 3.2 and earlier, it may instead be interpreted relative to the implementation location.By specifying an absolute path, you can avoid version-dependent behavior.For example, if you write renameFile("Test1.txt", "Test2.txt");, the current standard VCSSL runtime renames Test1.txt to Test2.txt in the same directory. However, in older versions, "Test2.txt" may be interpreted as a path relative to the implementation, so the file may be moved to the implementation directory where VCSSL.jar exists. Even in older versions, if you want to rename a file within the same directory, write something like renameFile("hoge1.txt", getFilePath("hoge2.txt", getFilePath(".")) );.
|
| Parameters |
(string type) pathOrName : The name or path of the target file. (string type) newName : The new name or destination path. To avoid dependency on older versions or implementations, specifying an absolute path is recommended. |
| Return | (void type) |
| Name | copyFile |
| Declaration | void copyFile( string inputPath, string outputPath ) |
| Description | Copies a file. |
| Parameters |
(string type) inputPath : The name or path of the source file. (string type) outputPath : The name or path of the destination file. |
| Return | (void type) |
| Name | getFilePath |
| Declaration | string getFilePath( string pathOrName ) |
| Description | Gets and returns the absolute path from a file name or relative path. |
| Parameters | (string type) pathOrName : The file name or relative path of the target file. |
| Return | (string type) The absolute path of the target file. |
| Name | getFilePath |
| Declaration | string getFilePath( string pathOrName, int type ) |
| Description | Gets and returns an absolute path, relative path, or parent-directory path from a file name or path. |
| Parameters |
(string type) pathOrName : The name or path of the target file. (int type) type : The type of path to obtain. Specify ABSOLUTE, RELATIVE, or PARENT, which represent absolute path, relative path, and parent-directory path respectively. |
| Return | (string type) The path of the target file. The kind of path is specified by the argument type. |
| Name | getFilePath |
| Declaration | string getFilePath( string pathOrName, string directory ) |
| Description | Converts and returns a file name or relative path, interpreted from the specified base directory, as an absolute path. |
| Parameters |
(string type) pathOrName : The name or relative path of the target file as seen from the base directory. (string type) directory : The base directory of the relative path. Specify it as a name or relative path based on the executed program, or as an absolute path. |
| Return | (string type) The absolute path of the target file. |
| Name | getFilePath |
| Declaration | string getFilePath( string pathOrName, string directory, int type ) |
| Description | Converts a file name or relative path interpreted from the specified base directory into an absolute path, a relative path based on the executed program, or a parent-directory path based on the executed program. |
| Parameters |
(string type) pathOrName : The name or path of the target file. (string type) directory : The base directory of the relative path. Specify it as a name or relative path based on the executed program, or as an absolute path. (int type) type : The type of path to obtain. Specify ABSOLUTE, RELATIVE, or PARENT, which represent absolute path, relative path, and parent-directory path respectively. |
| Return | (string type) The path of the target file. The kind of path is specified by the argument type. |
| Name | getFilePath |
| Declaration | string[ ] getFilePath( int target ) |
| Description | Gets the paths of special locations in the runtime environment or operating system. |
| Parameters | (int type) target : The kind of special location to obtain. Specify HOME, ROOT, or TMP. They mean the user's home directory, the root directory, and the temporary-file directory provided by the computer, respectively. |
| Return | (string[] type) The path of the special location. The location is specified by the argument target. The behavior when obtaining ROOT depends on the operating system. On operating systems without a single root, an array of drive names will probably be returned. |
| Name | getMainDirectory |
| Declaration | string getMainDirectory() |
| Description |
Returns the path of the directory containing the executed program. It can now be obtained by getFilePath("."). This function is supported for compatibility. |
| Return | (string type) The path of the directory containing the executed program. |
| Name | getHomeDirectory |
| Declaration | string getHomeDirectory() |
| Description |
Returns the path of the home directory. It can now be obtained by getFilePath( HOME ). This function is supported for compatibility. |
| Return | (string type) The path of the home directory. |
| Name | getRootDirectory |
| Declaration | string[ ] getRootDirectory() |
| Description |
Returns the path of the root directory. It can now be obtained by getFilePath( ROOT ). This function is supported for compatibility. |
| Return | (string[] type) The path of the root directory. |
| Name | getParentDirectory |
| Declaration | string getParentDirectory( string pathOrName ) |
| Description |
Returns the path of the parent directory. It can now be obtained by getFilePath( pathOrName, PARENT ). This function is supported for compatibility. |
| Parameters | (string type) pathOrName : The name or path of the target file. |
| Return | (string type) The path of the parent directory. |
| Name | getFileRelativePath |
| Declaration | string getFileRelativePath( string pathOrName, string directory ) |
| Description |
Converts and returns a relative path based on the specified directory into a relative path based on the executed program. It can now be obtained by getFilePath( pathOrName, directory, RELATIVE ). This function is supported for compatibility. |
| Parameters |
(string type) pathOrName : The name or path of the target file. (string type) directory : The path of the base directory. |
| Return | (string type) The relative path. |
| Name | getFileList |
| Declaration | string[ ] getFileList( string pathOrName ) |
| Description |
Gets the list of file names directly under the specified directory. It can now be obtained by listDirectory( pathOrName ). This function is supported for compatibility. In this function, the ordering of file names depends on the environment and operating system. Processing that assumes a specific order is not recommended. The newer listDirectory( pathOrName ) can accept sorting options. |
| Parameters | (string type) pathOrName : The name or path of the target directory. |
| Return | (string[] type) The list of file names directly under the specified directory (the order depends on the environment). |