Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
en:docs:fapi:doschgfileptr [2018/09/02 14:52] – prokushev | en:docs:fapi:doschgfileptr [2021/09/17 04:31] (current) – prokushev | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | {{logos:os2.gif? | + | {{page>en:templates:fapiint}} |
====== DosChgFilePtr ====== | ====== DosChgFilePtr ====== | ||
This call moves the read/write pointer in accordance with the type of move specified. | This call moves the read/write pointer in accordance with the type of move specified. | ||
- | ==Syntax== | + | ===== Syntax |
- | | + | <code c> |
+ | DosChgFilePtr (FileHandle, | ||
+ | </ | ||
- | ==Parameters== | + | ===== Parameters |
- | | + | |
- | * Distance (LONG) - input : The offset to move, in bytes. | + | |
- | * MoveType (USHORT) - input : Method of moving. Specifies a location in the file from where Distance to move the read/write pointer starts. Values and their meanings are: | + | * Distance ([[LONG]]) - input : The offset to move, in bytes. |
+ | * MoveType ([[USHORT]]) - input : Method of moving. Specifies a location in the file from where Distance to move the read/write pointer starts. Values and their meanings are: | ||
^ Value ^ Definition ^ | ^ Value ^ Definition ^ | ||
Line 19: | Line 22: | ||
| 2 | End of the file. Use this method to determine a file's size. | | | 2 | End of the file. Use this method to determine a file's size. | | ||
- | * NewPointer (PULONG) - output : Address of the new pointer location. | + | * NewPointer ([[PULONG]]) - output : Address of the new pointer location. |
- | ==Return Code== | + | ===== Return Code ===== |
- | | + | rc ([[USHORT]]) - return |
| | ||
Return code descriptions are: | Return code descriptions are: | ||
Line 31: | Line 34: | ||
* 6 ERROR_INVALID_HANDLE | * 6 ERROR_INVALID_HANDLE | ||
- | ==Remarks== | + | ===== Remarks ===== |
The read/write pointer in a file is a signed 32-bit number. A negative value moves the pointer backward in the file. A positive value moves the pointer forward. DosChgFilePtr cannot be used to seek to a negative position in the file. | The read/write pointer in a file is a signed 32-bit number. A negative value moves the pointer backward in the file. A positive value moves the pointer forward. DosChgFilePtr cannot be used to seek to a negative position in the file. | ||
This call may not be used for a character device or pipe. | This call may not be used for a character device or pipe. | ||
- | ==Example Code== | + | ===== Example Code ===== |
- | ===C Binding=== | + | |
- | #define INCL_DOSFILEMGR | + | ==== C Binding ==== |
- | + | ||
- | USHORT | + | |
- | + | ||
- | HFILE FileHandle; | + | |
- | LONG | + | |
- | USHORT | + | |
- | PULONG | + | |
- | + | ||
- | USHORT | + | |
+ | <code c> | ||
+ | #define INCL_DOSFILEMGR | ||
+ | |||
+ | USHORT | ||
+ | |||
+ | HFILE FileHandle; | ||
+ | LONG | ||
+ | USHORT | ||
+ | PULONG | ||
+ | |||
+ | USHORT | ||
+ | </ | ||
This example opens file test.dat, writes some data, and resets the file pointer to the beginning of the file. | This example opens file test.dat, writes some data, and resets the file pointer to the beginning of the file. | ||
+ | <code c> | ||
+ | #define INCL_DOSFILEMGR | ||
- | #define INCL_DOSFILEMGR | + | #define OPEN_FILE 0x01 |
- | + | #define CREATE_FILE 0x10 | |
- | | + | #define FILE_ARCHIVE 0x20 |
- | #define CREATE_FILE 0x10 | + | #define FILE_EXISTS OPEN_FILE |
- | #define FILE_ARCHIVE 0x20 | + | #define FILE_NOEXISTS CREATE_FILE |
- | #define FILE_EXISTS OPEN_FILE | + | #define DASD_FLAG 0 |
- | #define FILE_NOEXISTS CREATE_FILE | + | #define INHERIT 0x80 |
- | #define DASD_FLAG 0 | + | #define WRITE_THRU 0 |
- | #define INHERIT 0x80 | + | #define FAIL_FLAG 0 |
- | #define WRITE_THRU 0 | + | #define SHARE_FLAG 0x10 |
- | #define FAIL_FLAG 0 | + | #define ACCESS_FLAG 0x02 |
- | #define SHARE_FLAG 0x10 | + | |
- | #define ACCESS_FLAG 0x02 | + | |
- | + | ||
- | #define FILE_NAME " | + | |
- | #define FILE_SIZE 800L | + | |
- | #define FILE_ATTRIBUTE FILE_ARCHIVE | + | |
- | #define RESERVED 0L | + | |
- | + | ||
- | HFILE | + | |
- | USHORT | + | |
- | USHORT | + | |
- | PUSHORT Local | + | |
- | PSZ | + | |
- | USHORT | + | |
- | + | ||
- | | + | |
- | | + | |
- | | + | |
- | & | + | |
- | & | + | |
- | FILE_SIZE, | + | |
- | FILE_ATTRIBUTE, | + | |
- | FILE_EXISTS | FILE_NOEXISTS, | + | |
- | DASD_FLAG | INHERIT | /* Open mode of the file */ | + | |
- | WRITE_THRU | FAIL_FLAG | | + | |
- | SHARE_FLAG | ACCESS_FLAG, | + | |
- | RESERVED)) | + | |
- | if(!DosWrite(FileHandle, | + | |
- | | + | |
- | | + | |
- | & | + | |
- | rc = DosChgFilePtr(FileHandle, | + | |
- | MOVE_DIST, | + | |
- | FILE_BEG, | + | |
- | & | + | |
+ | #define FILE_NAME " | ||
+ | #define FILE_SIZE 800L | ||
+ | #define FILE_ATTRIBUTE FILE_ARCHIVE | ||
+ | #define RESERVED 0L | ||
+ | |||
+ | HFILE | ||
+ | USHORT | ||
+ | USHORT | ||
+ | PUSHORT Local | ||
+ | PSZ | ||
+ | USHORT | ||
- | ===MASM Binding=== | + | Action |
+ | strcpy(FileData, | ||
+ | if(!DosOpen(FILE_NAME, | ||
+ | & | ||
+ | & | ||
+ | FILE_SIZE, | ||
+ | FILE_ATTRIBUTE, | ||
+ | FILE_EXISTS | FILE_NOEXISTS, | ||
+ | DASD_FLAG | INHERIT | /* Open mode of the file */ | ||
+ | WRITE_THRU | FAIL_FLAG | | ||
+ | SHARE_FLAG | ACCESS_FLAG, | ||
+ | RESERVED)) | ||
+ | if(!DosWrite(FileHandle, | ||
+ | | ||
+ | | ||
+ | & | ||
+ | | ||
+ | MOVE_DIST, | ||
+ | FILE_BEG, | ||
+ | & | ||
+ | </ | ||
- | EXTRN DosChgFilePtr: | + | ==== MASM Binding ==== |
- | INCL_DOSFILEMGR | + | |
- | + | ||
- | PUSH | + | |
- | PUSH | + | |
- | PUSH | + | |
- | PUSH@ DWORD | + | |
- | CALL | + | |
+ | <code asm> | ||
+ | EXTRN DosChgFilePtr: | ||
+ | INCL_DOSFILEMGR | ||
+ | | ||
+ | PUSH | ||
+ | PUSH | ||
+ | PUSH | ||
+ | PUSH@ DWORD | ||
+ | CALL | ||
+ | </ | ||
Returns WORD | Returns WORD | ||
- | == Note === | + | ===== Note ===== |
Text based on http:// | Text based on http:// |