C++ Native Functions: com.ibm.streams.teda.file
SPL standard and specialized toolkits > com.ibm.streams.teda 1.0.2 > com.ibm.streams.teda.file > C++ Native Functions
- 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.