C++ Native Functions: com.teracloud.streams.teda.file
- public stateful boolean createDirectory(rstring path, mutable int32 errorCode)
-
Attempts to create the directory that the path variable identifies, as if by ISO/IEC 9945 mkdir() with a second argument of S_IRWXU|S_IRWXG|S_IRWXO.
The function creates parent directories as needed. It succeeds even if the directory already exists.
The behavior is similar to the Linux command mkdir -p <path>.
Example
rstring path = "/my_directory/my_sub_directory"; mutable int32 errorCode = 0; assert(createDirectory(path, errorCode), "cannot create directory '" + path + "', errno: " + (rstring)errorCode + ", " + strerror(errorCode));
- Parameters
-
- path
-
The absolute path of the directory that will be created. Relative paths are not supported. Use, for example, the spl.utility::dataDirectory() SPL function in your SPL application to build absolute paths that are relative to the data directory.
- errorCode
-
Set to 0 on success, or errno value on failure.
- Returns
-
The result of the function operation. A true return indicates that the function succeeded, either because the directory exists or it was created. A false return indicates that the function failed, and the errorCode offers additional information.
- public stateful boolean rename(rstring oldName, rstring newName, mutable int32 errorCode)
-
Renames a file or directory, as if by ISO/IEC 9945 rename().
If the oldName and newName paths specify different locations, the file or directory is moved to the new location if that is supported by the system.
The specified paths must be absolute paths. Use, for example, the spl.utility::dataDirectory() SPL function in your SPL application to build absolute paths that are relative to the data directory.
Example
rstring oldPath = "/my_directory/my_sub_directory/my_file.txt"; rstring newPath = "/my_directory/my_other_sub_directory/another_filename.txt"; mutable int32 errorCode = 0; assert(rename(oldPath, newPath, errorCode), "cannot rename '" + oldPath + "' to '" + newPath + "', errno: " + (rstring)errorCode + ", " + strerror(errorCode));
- Parameters
-
- oldName
-
The absolute path of the file or directory that will be renamed or moved. Relative paths are not supported.
- newName
-
The absolute path of the file or directory into which the file or directory will renamed or moved. Relative paths are not supported.
- errorCode
-
Set to 0 on success, or errno value on failure
- Returns
-
The result of the function operation. A true return indicates that the function succeeded because the file or directory is renamed. A false return indicates that the function failed, and the errorCode offers additional information.
- public stateful boolean space(rstring path, mutable uint64 capacity, mutable uint64 free, mutable uint64 available, mutable int32 errorCode)
-
Returns space information about a mounted file system.
See the Boost documentation for more details: boost::filesystem::space
- Parameters
-
- path
-
Specifies the path name of any file within the mounted file system.
- capacity
-
If the function succeeds, it stores the disk space capacity in this return parameter. In case of failure, the value stays unchanged.
- free
-
If the function succeeds, it stores the free disk space in this return parameter. In case of failure, the value stays unchanged.
- available
-
If the function succeeds, it stores the free disk space available to a non-privileged process in this return parameter. In case of failure, the value stays unchanged.
- errorCode
-
If the function fails, it stores the error code value in this return parameter.
- Returns
-
On success, true is returned. On error, false is returned, and errorCode is set appropriately (errno).
- public stateful boolean symlink(rstring target, rstring link, mutable int32 errorCode)
-
Creates a symbolic link in the file system.
The specified paths must be absolute paths. Use, for example, the spl.utility::dataDirectory() SPL function in your SPL application to build absolute paths that are relative to the data directory.
See the following link for more details: http://pubs.opengroup.org/onlinepubs/000095399/functions/symlink.html
- Parameters
-
- target
-
Specifies the file that is linked.
- link
-
Specifies the link path.
- errorCode
-
If the function fails, it stores the errno value in this return parameter.
- Returns
-
On success, true is returned. On error, false is returned, and errorCode is set appropriately (errno).