Job Management Partner 1/Software Distribution Automatic Installation Tool Description and Reference

[Contents][Glossary][Index][Back][Next]

AIT_FileOpen

Description

Opens an existing file, or creates a new file in set access mode.

Format

bool AIT_FileOpen  (
  string strFileName,     // Filename
  integer nAccessMode,    // Access mode
  integer nOperation,     // How to create
  integer nFileHandle     // File handle
);

Parameters

strFileName (input)

Specify the name of a file you want to create or open.

nAccessMode (input)

Specify mode of access to a file, which must be one or combination of the following values.

Value Description
GENERIC_READ Specify access to a file to be read. You can read data from the file and move the file pointer. To set mode of reading/writing access, specify the mode in combination with GENERIC_WRITE.
GENERIC_WRITE Specify access to a file to be programmed. You can program the file with data, and move the file pointer. To set mode of reading/writing access, specify the mode in combination with GENERIC_READ.

nOperation (input)

Specify how to handle a file when it exists or does not exist. You have to set one of the following values.

Value Description
CREATE_NEW Creates a file. If a specified file already exists, the function will not be executed successfully.
CREATE_ALWAYS Creates a new file. If a specified file already exists, the function overwrites the file.
OPEN_EXISTING Opens a file. If a specified file does not exist, the function will not be executed successfully.
OPEN_ALWAYS Opens a specified file if it exists. If a specified file does not exist, it is created.
TRUNCATE_EXISTING Opens a file. The opened file is arranged for the 0-byte size. You have to specify at least GENERIC_WRITE access in a calling process to open a file. If no file exists, the function will not be executed successfully.

nFileHandle (output)

Specify a variable for receiving a file handle. When the function returns, the variable stores the file handle.

Return values

The return value is true if the function was executed normally, and false if not. If the function has returned false, you can use AIT_GetLastError to acquire an extended error code. The following gives the error codes that AIT_GetLastError may return.

Extended error number Error code
2 ERROR_FILE_NOT_FOUND
3 ERROR_PATH_NOT_FOUND
4 ERROR_TOO_MANY_OPEN_FILES
5 ERROR_ACCESS_DENIED
6 ERROR_INVALID_HANDLE
8 ERROR_NOT_ENOUGH_MEMORY
14 ERROR_OUTOFMEMORY
15 ERROR_INVALID_DRIVE
18 ERROR_NO_MORE_FILES
19 ERROR_WRITE_PROTECT
21 ERROR_NOT_READY
32 ERROR_SHARING_VIOLATION
33 ERROR_LOCK_VIOLATION
53 ERROR_BAD_NETPATH
80 ERROR_FILE_EXISTS
82 ERROR_CANNOT_MAKE
87 ERROR_INVALID_PARAMETER
112 ERROR_DISK_FULL
123 ERROR_INVALID_NAME
148 ERROR_PATH_BUSY
161 ERROR_BAD_PATHNAME
183 ERROR_ALREADY_EXISTS
206 ERROR_FILENAME_EXCED_RANGE
1005 ERROR_UNRECOGNIZED_VOLUME
1210 ERROR_INVALID_COMPUTERNAME
1214 ERROR_INVALID_NETNAME
1231 ERROR_NETWORK_UNREACHABLE
1392 ERROR_FILE_CORRUPT

Note

Use the AIT_FileClose function to close a file handle returned by AIT_OpenFile.