首页 / base / oaFile

oaFile

模块: oapy._oa._base 导入: from oapy._oa import _base

概览

oaFileoapy 中可用,可通过 _base 模块访问。

本页汇总 oaFile 当前在 oapy 中可用的 Python 接口。

详细说明

The oaFile utility class implements an object for managing a disk file, including functions for getting system information about, locking, and removing a file。

构造函数

_base.oaFile(nameIn)

obj = _base.oaFile(nameIn)

方法总览

状态 Python 调用
obj.open(modeIn)
obj.close()
obj.flush()
obj.read(data, numBytes)
obj.write(data, numBytes)
obj.exists()
obj.isOpen()
obj.isNonEmpty()
obj.getMode()
obj.getSize()
obj.getLastWriteTime()
obj.getCreateTime()
_base.oaFile.copyFile(srcPath, dstPath)

方法说明

obj.open(modeIn)

绑定状态: 已绑定

Python 调用: obj.open(modeIn)

This function opens this file using the specified access mode。

参数

  • modeIn: The mode in which to open the file 'r' for read 'w' for write 'a' for append。

异常

  • oacInvalidFileAccessMode
  • oacFileOpenFailed

Python 示例

from oapy._oa import _base

# assume obj is a oaFile
obj.open(modeIn)

obj.close()

绑定状态: 已绑定

Python 调用: obj.close()

This function closes the file。

异常

  • oacFileCloseFailed

Python 示例

from oapy._oa import _base

# assume obj is a oaFile
obj.close()

obj.flush()

绑定状态: 已绑定

Python 调用: obj.flush()

This function flushes any buffered output to disk。

Python 示例

from oapy._oa import _base

# assume obj is a oaFile
obj.flush()

obj.read(data, numBytes)

绑定状态: 已绑定

Python 调用: obj.read(data, numBytes)

This function reads data from the file。 The file must be open in a readable mode。 The function returns the actual number of bytes read, which may be less than the number of bytes requested。 An exception will be thrown if any IO error occurs。

参数

  • data: The buffer that this function will fill in with the bytes read。
  • numBytes: The number of bytes requested。

异常

  • oacFileReadFailed

Python 示例

from oapy._oa import _base

# assume obj is a oaFile
obj.read(data, numBytes)

obj.write(data, numBytes)

绑定状态: 已绑定

Python 调用: obj.write(data, numBytes)

This function writes the data to the file。 The file must be open in a writable mode。 An exception will be thrown if any IO error occurs。

参数

  • data: The buffer containing the bytes to be written。
  • numBytes: The number of bytes to write。

异常

  • oacFileWriteFailed

Python 示例

from oapy._oa import _base

# assume obj is a oaFile
obj.write(data, numBytes)

obj.exists()

绑定状态: 已绑定

Python 调用: obj.exists()

This function returns a boolean value that indicates if this file exists on disk。 从 oaFSComponent 重新实现。

Python 示例

from oapy._oa import _base

# assume obj is a oaFile
obj.exists()

obj.isOpen()

绑定状态: 已绑定

Python 调用: obj.isOpen()

This function returns true if this file is open。

Python 示例

from oapy._oa import _base

# assume obj is a oaFile
obj.isOpen()

obj.isNonEmpty()

绑定状态: 已绑定

Python 调用: obj.isNonEmpty()

This function returns true if this file exists on disk and the size is > 0。 This function is provided for efficiency so that the file does not have to be looked up twice。

Python 示例

from oapy._oa import _base

# assume obj is a oaFile
obj.isNonEmpty()

obj.getMode()

绑定状态: 已绑定

Python 调用: obj.getMode()

This function returns a string containing the current mode used to access this file。

Python 示例

from oapy._oa import _base

# assume obj is a oaFile
obj.getMode()

obj.getSize()

绑定状态: 已绑定

Python 调用: obj.getSize()

This function returns the size of this file, in bytes。

异常

  • oacFileGetInfoFailed

Python 示例

from oapy._oa import _base

# assume obj is a oaFile
obj.getSize()

obj.getLastWriteTime()

绑定状态: 已绑定

Python 调用: obj.getLastWriteTime()

This function returns the last modified time of the file of the file on the disk (the last time the file was written)。

异常

  • oacFileGetInfoFailed

Python 示例

from oapy._oa import _base

# assume obj is a oaFile
obj.getLastWriteTime()

obj.getCreateTime()

绑定状态: 已绑定

Python 调用: obj.getCreateTime()

This function returns the creation time of the file on the disk。 The format of the time is unit of seconds from Jan, 1, 1970, 0 hour, 0 min, 0 sec。

异常

  • oacFileGetInfoFailed

Python 示例

from oapy._oa import _base

# assume obj is a oaFile
obj.getCreateTime()

_base.oaFile.copyFile(srcPath, dstPath)

绑定状态: 已绑定

Python 调用: _base.oaFile.copyFile(srcPath, dstPath)

This function copies the source file to the destination file。 The source file must be readable, and the destination file must be writable。 If the destination file exists, it will be overwritten。

参数

  • srcPath: absolute or relative path, including file name, of the source file。
  • dstPath: absolute or relative path, including file name, of the destination file。

异常

  • oacFileCopyFailed
  • oacFileSetAttrFailed

Python 示例

from oapy._oa import _base

_base.oaFile.copyFile(srcPath, dstPath)