oaFSComponent
模块: oapy._oa._base
导入: from oapy._oa import _base
概览
oaFSComponent 在 oapy 中可用,可通过 _base 模块访问。
本页汇总 oaFSComponent 当前在 oapy 中可用的 Python 接口。
详细说明
The FSComponent class implements a file system component, which may be either a file or a directory。
构造函数
_base.oaFSComponent(nameIn)
obj = _base.oaFSComponent(nameIn)
方法总览
| 状态 | Python 调用 |
|---|---|
| ✅ | obj.destroy() |
| ✅ | obj.rename(newName) |
| ✅ | obj.exists() |
| ✅ | obj.isFile() |
| ✅ | obj.isDir() |
| ✅ | obj.isReadable() |
| ✅ | obj.isWritable() |
| ✅ | obj.isInCWD() |
| ✅ | obj.isSameDiskFile(file) |
| ✅ | obj.isSymbolicLink() |
| ✅ | obj.getName() |
| ✅ | obj.getFullName(pathName) |
方法说明
obj.destroy()
绑定状态: 已绑定
Python 调用: obj.destroy()
This function removes this file system component from the disk。 If the component is a directory, it will remove the contents of the directory and then delete the directory itself。
异常
oacUnableToRemove。
Python 示例
from oapy._oa import _base
# assume obj is a oaFSComponent
obj.destroy()
obj.rename(newName)
绑定状态: 已绑定
Python 调用: obj.rename(newName)
This function renames this file system component to the specified newName。 If the object is a file, the file must not be open at the time, since the handles will still point to the old file。 If running on Windows OS, an exception is thrown if a file system component with the new name already exists。
参数
newName: New name path。 The path may be relative to the current working directory, or a fully qualified path name。
异常
oacUnableToRemove。
Python 示例
from oapy._oa import _base
# assume obj is a oaFSComponent
obj.rename(newName)
obj.exists()
绑定状态: 已绑定
Python 调用: obj.exists()
This function returns true if the file system component associated with the name exists on disk。 在 oaFile 和 oaDir 中重新实现。
Python 示例
from oapy._oa import _base
# assume obj is a oaFSComponent
obj.exists()
obj.isFile()
绑定状态: 已绑定
Python 调用: obj.isFile()
This function returns true if this file system component is a file (not a directory)。
Python 示例
from oapy._oa import _base
# assume obj is a oaFSComponent
obj.isFile()
obj.isDir()
绑定状态: 已绑定
Python 调用: obj.isDir()
This function returns true if this file system component is a directory。
Python 示例
from oapy._oa import _base
# assume obj is a oaFSComponent
obj.isDir()
obj.isReadable()
绑定状态: 已绑定
Python 调用: obj.isReadable()
This function returns true if the file system component is readable by the calling application。
Python 示例
from oapy._oa import _base
# assume obj is a oaFSComponent
obj.isReadable()
obj.isWritable()
绑定状态: 已绑定
Python 调用: obj.isWritable()
This function returns true if the file system component is writable, respectively。 Note that the isWritable check requires the component to exist on disk。
Python 示例
from oapy._oa import _base
# assume obj is a oaFSComponent
obj.isWritable()
obj.isInCWD()
绑定状态: 已绑定
Python 调用: obj.isInCWD()
This function checks the file system component given by path to see if it is in the current working directory。 Note that a file that is a link in the CWD will return true。 This is the algorithm used: 1) Remove the file portion of the oaFSComponent name in order to get the directory。 2) Get the current working directory。 3) Use isSameDiskFile() to compare the two directories。
Python 示例
from oapy._oa import _base
# assume obj is a oaFSComponent
obj.isInCWD()
obj.isSameDiskFile(file)
绑定状态: 已绑定
Python 调用: obj.isSameDiskFile(file)
This function compares the current file system component to the given system file component in order to determine if they point to the same device and inode and therefore refer to the same file。 Returns true if the device and inode of each component are the same。 Returns false if the device or inode are not the same, or if either component cannot be opened。
参数
fileComponent: File system component to check this one against。
Python 示例
from oapy._oa import _base
# assume obj is a oaFSComponent
obj.isSameDiskFile(file)
obj.isSymbolicLink()
绑定状态: 已绑定
Python 调用: obj.isSymbolicLink()
This function returns true if the file system component is a symbolic link。 On platforms that do not support symbolic links, it always returns false。
Python 示例
from oapy._oa import _base
# assume obj is a oaFSComponent
obj.isSymbolicLink()
obj.getName()
绑定状态: 已绑定
Python 调用: obj.getName()
This function returns the name (path) of this file system component。
Python 示例
from oapy._oa import _base
# assume obj is a oaFSComponent
obj.getName()
obj.getFullName(pathName)
绑定状态: 已绑定
Python 调用: obj.getFullName(pathName)
This function returns the full path to the library relative to the local host。 This is also called the "real" name or the "canonicalized" name。
参数
pathName: Reference to string to return the pathName in。
异常
oacGetFullPathFailed。
Python 示例
from oapy._oa import _base
# assume obj is a oaFSComponent
obj.getFullName(pathName)