📄 prio.h
字号:
NSPR_API(PRFileDesc*) PR_OpenFile(
const char *name, PRIntn flags, PRIntn mode);
#ifdef MOZ_UNICODE
/*
* EXPERIMENTAL: This function may be removed in a future release.
*/
NSPR_API(PRFileDesc*) PR_OpenFileUTF16(
const PRUnichar *name, PRIntn flags, PRIntn mode);
#endif /* MOZ_UNICODE */
/*
**************************************************************************
* FUNCTION: PR_Close
* DESCRIPTION:
* Close a file or socket.
* INPUTS:
* PRFileDesc *fd
* a pointer to a PRFileDesc.
* OUTPUTS:
* None.
* RETURN:
* PRStatus
* SIDE EFFECTS:
* RESTRICTIONS:
* None.
* MEMORY:
* The dynamic memory pointed to by the argument fd is freed.
**************************************************************************
*/
NSPR_API(PRStatus) PR_Close(PRFileDesc *fd);
/*
**************************************************************************
* FUNCTION: PR_Read
* DESCRIPTION:
* Read bytes from a file or socket.
* The operation will block until either an end of stream indication is
* encountered, some positive number of bytes are transferred, or there
* is an error. No more than 'amount' bytes will be transferred.
* INPUTS:
* PRFileDesc *fd
* pointer to the PRFileDesc object for the file or socket
* void *buf
* pointer to a buffer to hold the data read in.
* PRInt32 amount
* the size of 'buf' (in bytes)
* OUTPUTS:
* RETURN:
* PRInt32
* a positive number indicates the number of bytes actually read in.
* 0 means end of file is reached or the network connection is closed.
* -1 indicates a failure. The reason for the failure is obtained
* by calling PR_GetError().
* SIDE EFFECTS:
* data is written into the buffer pointed to by 'buf'.
* RESTRICTIONS:
* None.
* MEMORY:
* N/A
* ALGORITHM:
* N/A
**************************************************************************
*/
NSPR_API(PRInt32) PR_Read(PRFileDesc *fd, void *buf, PRInt32 amount);
/*
***************************************************************************
* FUNCTION: PR_Write
* DESCRIPTION:
* Write a specified number of bytes to a file or socket. The thread
* invoking this function blocks until all the data is written.
* INPUTS:
* PRFileDesc *fd
* pointer to a PRFileDesc object that refers to a file or socket
* const void *buf
* pointer to the buffer holding the data
* PRInt32 amount
* amount of data in bytes to be written from the buffer
* OUTPUTS:
* None.
* RETURN: PRInt32
* A positive number indicates the number of bytes successfully written.
* A -1 is an indication that the operation failed. The reason
* for the failure is obtained by calling PR_GetError().
***************************************************************************
*/
NSPR_API(PRInt32) PR_Write(PRFileDesc *fd,const void *buf,PRInt32 amount);
/*
***************************************************************************
* FUNCTION: PR_Writev
* DESCRIPTION:
* Write data to a socket. The data is organized in a PRIOVec array. The
* operation will block until all the data is written or the operation
* fails.
* INPUTS:
* PRFileDesc *fd
* Pointer that points to a PRFileDesc object for a socket.
* const PRIOVec *iov
* An array of PRIOVec. PRIOVec is a struct with the following
* two fields:
* char *iov_base;
* int iov_len;
* PRInt32 iov_size
* Number of elements in the iov array. The value of this
* argument must not be greater than PR_MAX_IOVECTOR_SIZE.
* If it is, the method will fail (PR_BUFFER_OVERFLOW_ERROR).
* PRIntervalTime timeout
* Time limit for completion of the entire write operation.
* OUTPUTS:
* None
* RETURN:
* A positive number indicates the number of bytes successfully written.
* A -1 is an indication that the operation failed. The reason
* for the failure is obtained by calling PR_GetError().
***************************************************************************
*/
#define PR_MAX_IOVECTOR_SIZE 16 /* 'iov_size' must be <= */
NSPR_API(PRInt32) PR_Writev(
PRFileDesc *fd, const PRIOVec *iov, PRInt32 iov_size,
PRIntervalTime timeout);
/*
***************************************************************************
* FUNCTION: PR_Delete
* DESCRIPTION:
* Delete a file from the filesystem. The operation may fail if the
* file is open.
* INPUTS:
* const char *name
* Path name of the file to be deleted.
* OUTPUTS:
* None.
* RETURN: PRStatus
* The function returns PR_SUCCESS if the file is successfully
* deleted, otherwise it returns PR_FAILURE.
***************************************************************************
*/
NSPR_API(PRStatus) PR_Delete(const char *name);
/**************************************************************************/
typedef enum PRFileType
{
PR_FILE_FILE = 1,
PR_FILE_DIRECTORY = 2,
PR_FILE_OTHER = 3
} PRFileType;
struct PRFileInfo {
PRFileType type; /* Type of file */
PROffset32 size; /* Size, in bytes, of file's contents */
PRTime creationTime; /* Creation time per definition of PRTime */
PRTime modifyTime; /* Last modification time per definition of PRTime */
};
struct PRFileInfo64 {
PRFileType type; /* Type of file */
PROffset64 size; /* Size, in bytes, of file's contents */
PRTime creationTime; /* Creation time per definition of PRTime */
PRTime modifyTime; /* Last modification time per definition of PRTime */
};
/****************************************************************************
* FUNCTION: PR_GetFileInfo, PR_GetFileInfo64
* DESCRIPTION:
* Get the information about the file with the given path name. This is
* applicable only to NSFileDesc describing 'file' types (see
* INPUTS:
* const char *fn
* path name of the file
* OUTPUTS:
* PRFileInfo *info
* Information about the given file is written into the file
* information object pointer to by 'info'.
* RETURN: PRStatus
* PR_GetFileInfo returns PR_SUCCESS if file information is successfully
* obtained, otherwise it returns PR_FAILURE.
***************************************************************************
*/
NSPR_API(PRStatus) PR_GetFileInfo(const char *fn, PRFileInfo *info);
NSPR_API(PRStatus) PR_GetFileInfo64(const char *fn, PRFileInfo64 *info);
#ifdef MOZ_UNICODE
/*
* EXPERIMENTAL: This function may be removed in a future release.
*/
NSPR_API(PRStatus) PR_GetFileInfo64UTF16(const PRUnichar *fn, PRFileInfo64 *info);
#endif /* MOZ_UNICODE */
/*
**************************************************************************
* FUNCTION: PR_GetOpenFileInfo, PR_GetOpenFileInfo64
* DESCRIPTION:
* Get information about an open file referred to by the
* given PRFileDesc object.
* INPUTS:
* const PRFileDesc *fd
* A reference to a valid, open file.
* OUTPUTS:
* Same as PR_GetFileInfo, PR_GetFileInfo64
* RETURN: PRStatus
* PR_GetFileInfo returns PR_SUCCESS if file information is successfully
* obtained, otherwise it returns PR_FAILURE.
***************************************************************************
*/
NSPR_API(PRStatus) PR_GetOpenFileInfo(PRFileDesc *fd, PRFileInfo *info);
NSPR_API(PRStatus) PR_GetOpenFileInfo64(PRFileDesc *fd, PRFileInfo64 *info);
/*
**************************************************************************
* FUNCTION: PR_Rename
* DESCRIPTION:
* Rename a file from the old name 'from' to the new name 'to'.
* INPUTS:
* const char *from
* The old name of the file to be renamed.
* const char *to
* The new name of the file.
* OUTPUTS:
* None.
* RETURN: PRStatus
**************************************************************************
*/
NSPR_API(PRStatus) PR_Rename(const char *from, const char *to);
/*
*************************************************************************
* FUNCTION: PR_Access
* DESCRIPTION:
* Determine accessibility of a file.
* INPUTS:
* const char *name
* path name of the file
* PRAccessHow how
* specifies which access permission to check for.
* It can be one of the following values:
* PR_ACCESS_READ_OK Test for read permission
* PR_ACCESS_WRITE_OK Test for write permission
* PR_ACCESS_EXISTS Check existence of file
* OUTPUTS:
* None.
* RETURN: PRStatus
* PR_SUCCESS is returned if the requested access is permitted.
* Otherwise, PR_FAILURE is returned. Additional information
* regarding the reason for the failure may be retrieved from
* PR_GetError().
*************************************************************************
*/
typedef enum PRAccessHow {
PR_ACCESS_EXISTS = 1,
PR_ACCESS_WRITE_OK = 2,
PR_ACCESS_READ_OK = 3
} PRAccessHow;
NSPR_API(PRStatus) PR_Access(const char *name, PRAccessHow how);
/*
*************************************************************************
* FUNCTION: PR_Seek, PR_Seek64
* DESCRIPTION:
* Moves read-write file offset
* INPUTS:
* PRFileDesc *fd
* Pointer to a PRFileDesc object.
* PROffset32, PROffset64 offset
* Specifies a value, in bytes, that is used in conjunction
* with the 'whence' parameter to set the file pointer. A
* negative value causes seeking in the reverse direction.
* PRSeekWhence whence
* Specifies how to interpret the 'offset' parameter in setting
* the file pointer associated with the 'fd' parameter.
* Values for the 'whence' parameter are:
* PR_SEEK_SET Sets the file pointer to the value of the
* 'offset' parameter
* PR_SEEK_CUR Sets the file pointer to its current location
* plus the value of the offset parameter.
* PR_SEEK_END Sets the file pointer to the size of the
* file plus the value of the offset parameter.
* OUTPUTS:
* None.
* RETURN: PROffset32, PROffset64
* Upon successful completion, the resulting pointer location,
* measured in bytes from the beginning of the file, is returned.
* If the PR_Seek() function fails, the file offset remains
* unchanged, and the returned value is -1. The error code can
* then be retrieved via PR_GetError().
*************************************************************************
*/
NSPR_API(PROffset32) PR_Seek(PRFileDesc *fd, PROffset32 offset, PRSeekWhence whence);
NSPR_API(PROffset64) PR_Seek64(PRFileDesc *fd, PROffset64 offset, PRSeekWhence whence);
/*
************************************************************************
* FUNCTION: PR_Available
* DESCRIPTION:
* Determine the amount of data in bytes available for reading
* in the given file or socket.
* INPUTS:
* PRFileDesc *fd
* Pointer to a PRFileDesc object that refers to a file or
* socket.
* OUTPUTS:
* None
* RETURN: PRInt32, PRInt64
* Upon successful completion, PR_Available returns the number of
* bytes beyond the current read pointer that is available for
* reading. Otherwise, it returns a -1 and the reason for the
* failure can be retrieved via PR_GetError().
************************************************************************
*/
NSPR_API(PRInt32) PR_Available(PRFileDesc *fd);
NSPR_API(PRInt64) PR_Available64(PRFileDesc *fd);
/*
************************************************************************
* FUNCTION: PR_Sync
* DESCRIPTION:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -