en:docs:fapi:doschgfileptr

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
Last revisionBoth sides next revision
en:docs:fapi:doschgfileptr [2018/08/26 13:38] – created prokusheven:docs:fapi:doschgfileptr [2021/08/20 03:22] prokushev
Line 1: Line 1:
 +{{page>en:templates:fapiint}}
 +====== 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==
- DosChgFilePtr (FileHandle, Distance, MoveType, NewPointer)+ 
 +  DosChgFilePtr (FileHandle, Distance, MoveType, NewPointer)
  
 ==Parameters== ==Parameters==
-;FileHandle (HFILE) - input : Handle returned by a previous DosOpen call. + 
-Distance (LONG) - input : The offset to move, in bytes. +  * FileHandle ([[HFILE]]) - input : Handle returned by a previous DosOpen call. 
-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. 
- '''Value        Definition''' +  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: 
-        Beginning of the file. + 
-        Current location of the read/write pointer. +Value Definition ^ 
-        End of the file. Use this method to determine a file's size. +Beginning of the file. | 
-NewPointer (PULONG) - output : Address of the new pointer location.+Current location of the read/write pointer. | 
 +End of the file. Use this method to determine a file's size. 
 + 
 +  NewPointer ([[PULONG]]) - output : Address of the new pointer location.
  
 ==Return Code== ==Return Code==
- rc (USHORT) - return+ 
 +rc ([[USHORT]]) - return 
 +  
 Return code descriptions are: Return code descriptions are:
-* 0 NO_ERROR + 
-* 1 ERROR_INVALID_FUNCTION +  * 0 NO_ERROR 
-* 6 ERROR_INVALID_HANDLE  +  * 1 ERROR_INVALID_FUNCTION 
 +  * 6 ERROR_INVALID_HANDLE  
  
 ==Remarks== ==Remarks==
Line 29: Line 38:
 ==Example Code== ==Example Code==
 ===C Binding=== ===C Binding===
-<PRE>+<code c>
 #define INCL_DOSFILEMGR #define INCL_DOSFILEMGR
  
Line 40: Line 49:
  
 USHORT           rc;            /* return code */ USHORT           rc;            /* return code */
-</PRE>+</code>
 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.
-<PRE>+<code c>
 #define INCL_DOSFILEMGR #define INCL_DOSFILEMGR
  
Line 61: Line 70:
 #define FILE_ATTRIBUTE FILE_ARCHIVE #define FILE_ATTRIBUTE FILE_ARCHIVE
 #define RESERVED 0L #define RESERVED 0L
 + 
 HFILE   FileHandle; HFILE   FileHandle;
 USHORT  Wrote; USHORT  Wrote;
Line 69: Line 78:
 USHORT  rc; USHORT  rc;
  
-   Action = 2; +Action = 2; 
-   strcpy(FileData, "Data..."); +strcpy(FileData, "Data..."); 
-   if(!DosOpen(FILE_NAME,                /* File path name */ +if(!DosOpen(FILE_NAME,                /* File path name */ 
-                &FileHandle,             /* File handle */ +            &FileHandle,             /* File handle */ 
-                &Action,                 /* Action taken */ +            &Action,                 /* Action taken */ 
-                FILE_SIZE,               /* File primary allocation */ +            FILE_SIZE,               /* File primary allocation */ 
-                FILE_ATTRIBUTE,          /* File attribute */ +            FILE_ATTRIBUTE,          /* File attribute */ 
-                FILE_EXISTS | FILE_NOEXISTS,      /* Open function type */ +            FILE_EXISTS | FILE_NOEXISTS,      /* Open function type */ 
-                DASD_FLAG | INHERIT |            /* Open mode of the file */ +            DASD_FLAG | INHERIT |            /* Open mode of the file */ 
-                WRITE_THRU | FAIL_FLAG | +            WRITE_THRU | FAIL_FLAG | 
-                SHARE_FLAG | ACCESS_FLAG, +            SHARE_FLAG | ACCESS_FLAG, 
-                RESERVED))               /* Reserved (must be zero) */ +            RESERVED))               /* Reserved (must be zero) */ 
-      if(!DosWrite(FileHandle,           /* File handle */ +    if(!DosWrite(FileHandle,           /* File handle */ 
-                   (PVOID) FileData,     /* User buffer */ +                 (PVOID) FileData,     /* User buffer */ 
-                   sizeof(FileData),     /* Buffer length */ +                 sizeof(FileData),     /* Buffer length */ 
-                   &Wrote))              /* Bytes written */ +                 &Wrote))              /* Bytes written */ 
-         rc = DosChgFilePtr(FileHandle,  /* File handle */ +       rc = DosChgFilePtr(FileHandle,  /* File handle */ 
-                            MOVE_DIST,   /* Distance to move in bytes */ +                          MOVE_DIST,   /* Distance to move in bytes */ 
-                            FILE_BEG,    /* Method of moving */ +                          FILE_BEG,    /* Method of moving */ 
-                            &Local);     /* New pointer location */ +                          &Local);     /* New pointer location */ 
-</PRE>+</code>
  
 ===MASM Binding=== ===MASM Binding===
-<PRE>+<code asm>
 EXTRN  DosChgFilePtr:FAR EXTRN  DosChgFilePtr:FAR
 INCL_DOSFILEMGR     EQU 1 INCL_DOSFILEMGR     EQU 1
 +  
 PUSH   WORD    FileHandle    ;File handle PUSH   WORD    FileHandle    ;File handle
 PUSH   DWORD   Distance      ;Distance to move in bytes PUSH   DWORD   Distance      ;Distance to move in bytes
Line 101: Line 110:
 PUSH@  DWORD   NewPointer    ;New Pointer Location (returned) PUSH@  DWORD   NewPointer    ;New Pointer Location (returned)
 CALL   DosChgFilePtr CALL   DosChgFilePtr
 +</code>
 Returns WORD Returns WORD
-</PRE> 
  
 +
 +== Note ===
 +
 +Text based on http://www.edm2.com/index.php/DosChgFilePtr
 +
 +{{page>en:templates:fapi}}