NXFileOpenEx

Opens a file (comprehensive interface).

Library:LibC
Classification:NKS
Service:File and Directory I/O

Syntax

  #include <nks/fsio.h> 
  
  int NXFileOpenEx (
     NXFileOpenSpec_t   *openSpec, 
     NXHandle_t         *fileHandle); 
  

Parameters

openSpec

(IN) Points to the NXFileOpenSpec_t structure, which contains open call parameters.

fileHandle

(OUT) Points to an integer-valued open file descriptor on success. On failure, return -1.

Return Values

If successful, returns 0 and an open file descriptor in fileHandle. Otherwise, returns an error code. On failure the new file remains unopened. However, if the request was to overwrite a file and NXFileOpenEx fails, the file might be destroyed in the process.

Decimal

Hex

Constant

Description

1

0x01

NX_ENOENT

A component of the path prefixes specified by pathname or pathCtx does not exist, or pathname is NULL. Alternatively, the file does not exist and the NX_O_CREATE mode is not specified.

4

0x04

NX_EBADF

Invalid directory handle.

5

0x05

NX_NOMEM

Insufficient memory to perform the operation.

6

0x06

NX_EACCES

Insufficient rights to the object.

7

0x07

NX_EEXIST

The specified file exists, and cannot be overwritten, and the NX_O_TRUNC mode was specified.

9

0x09

NX_EINVAL

A pathCtx was specified, but pathname indicates a full path.

12

0x0C

NX_ENOSPC

File system in which a new file is to be created does not have enough media space.

10

0x0A

NX_ENFILE

The system limit, if any, on the number of open files has been reached.

24

0x18

NX_EAGAIN

Resource exhaustion prevented successful completion of the call.

64

0x40

NX_EISDIR

A directory object that has the same name as the specified file exists.

65

0x41

NX_ENAMETOOLONG

The pathname contents are longer than system-permitted name length.

105

0x69

NX_ENOCONTEXT

The calling thread has no NKS context.

Remarks

NXFileOpenEx creates or opens a file and associates it with an open file handle that can be used to perform I/O operations on the file. If the file is successfully opened, a file handle (which can be used by all handle-based NDK file functions) is returned in the fileHandle parameter.

If the file is already open, the fosShareMode and fosMode fields are used to check whether the current open request can be allowed. If the file is not already open, fosShareMode and fosMode determine what kind of sharing is allowed (if any) for future opens on the file while it is still open.

Each call to NXFileOpenEx generates a new file descriptor, even when the same pathname is opened.

See Also

NXFileOpen