Jump to content

DosDelete: Difference between revisions

From EDM2
Created page with "==Description== Removes a file name from a directory. The deleted file may be recoverable. ==Syntax== <PRE> #define INCL_DOSFILEMGR #include <os2.h> PSZ pszFile; /* ..."
 
Ak120 (talk | contribs)
mNo edit summary
Line 1: Line 1:
==Description==
Removes a file name from a directory. The deleted file may be recoverable.
Removes a file name from a directory. The deleted file may be recoverable.


Line 11: Line 10:


ulrc = DosDelete(pszFile);
ulrc = DosDelete(pszFile);
</PRE>


</PRE>
==Parameters==
==Parameters==
; pszFile (PSZ) - input : Address of the name of the file to be deleted.
;pszFile (PSZ) - input : Address of the name of the file to be deleted.
 
==Return Code==
==Return Code==
  ulrc (APIRET) - returns
  ulrc (APIRET) - returns
DosDelete returns one of the following values:
DosDelete returns one of the following values:
*0 NO_ERROR
*2 ERROR_FILE_NOT_FOUND
*3 ERROR_PATH_NOT_FOUND
*5 ERROR_ACCESS_DENIED
*26 ERROR_NOT_DOS_DISK
*32 ERROR_SHARING_VIOLATION
*36 ERROR_SHARING_BUFFER_EXCEEDED
*87 ERROR_INVALID_PARAMETER
*206 ERROR_FILENAME_EXCED_RANGE


*0    NO_ERROR
* 2        ERROR_FILE_NOT_FOUND
* 3        ERROR_PATH_NOT_FOUND
* 5        ERROR_ACCESS_DENIED
* 26        ERROR_NOT_DOS_DISK
* 32        ERROR_SHARING_VIOLATION
* 36        ERROR_SHARING_BUFFER_EXCEEDED
* 87        ERROR_INVALID_PARAMETER
* 206        ERROR_FILENAME_EXCED_RANGE
==Remarks==
==Remarks==
Global file-name characters are not permitted in the name of the file to be deleted.
Global file-name characters are not permitted in the name of the file to be deleted.


Read-only files cannot be deleted by DosDelete. To delete a read-only file, you must first issue DosSetFileInfo to change the file's read-only attribute to zero, then delete the file.
Read-only files cannot be deleted by DosDelete. To delete a read-only file, you must first issue [[DosSetFileInfo]] to change the file's read-only attribute to zero, then delete the file.


If a storage directory for the drive has been defined with the SET DELDIR command, the UNDELETE command may recover the deleted file.
If a storage directory for the drive has been defined with the SET DELDIR command, the UNDELETE command may recover the deleted file.


DosDelete cannot be used to delete directories. Issue DosDeleteDir to delete a directory.  
DosDelete cannot be used to delete directories. Issue [[DosDeleteDir]] to delete a directory.  


==Example Code==
==Example Code==
Line 87: Line 86:
   return NO_ERROR;
   return NO_ERROR;
}
}
</PRE>


</PRE>
==Related Functions==
==Related Functions==
* [[OS2 API:CPI:DosDeleteDir|DosDeleteDir]]
*[[DosDeleteDir]]
* [[OS2 API:CPI:DosForceDelete|DosForceDelete]]
*[[DosForceDelete]]
* [[OS2 API:CPI:DosSetFileInfo|DosSetFileInfo]]
*[[DosSetFileInfo]]
 


[[Category:The OS/2 API Project]]
[[Category:Dos]]

Revision as of 05:21, 19 December 2016

Removes a file name from a directory. The deleted file may be recoverable.

Syntax

#define INCL_DOSFILEMGR
#include <os2.h>

PSZ       pszFile;  /*  Address of the name of the file to be deleted. */
APIRET    ulrc;     /*  Return Code. */

ulrc = DosDelete(pszFile);

Parameters

pszFile (PSZ) - input
Address of the name of the file to be deleted.

Return Code

ulrc (APIRET) - returns

DosDelete returns one of the following values:

  • 0 NO_ERROR
  • 2 ERROR_FILE_NOT_FOUND
  • 3 ERROR_PATH_NOT_FOUND
  • 5 ERROR_ACCESS_DENIED
  • 26 ERROR_NOT_DOS_DISK
  • 32 ERROR_SHARING_VIOLATION
  • 36 ERROR_SHARING_BUFFER_EXCEEDED
  • 87 ERROR_INVALID_PARAMETER
  • 206 ERROR_FILENAME_EXCED_RANGE

Remarks

Global file-name characters are not permitted in the name of the file to be deleted.

Read-only files cannot be deleted by DosDelete. To delete a read-only file, you must first issue DosSetFileInfo to change the file's read-only attribute to zero, then delete the file.

If a storage directory for the drive has been defined with the SET DELDIR command, the UNDELETE command may recover the deleted file.

DosDelete cannot be used to delete directories. Issue DosDeleteDir to delete a directory.

Example Code

This example creates and deletes a file named "TEST.DAT".

#define INCL_DOSFILEMGR          /* File Manager values */
#define INCL_DOSERRORS           /* DOS error values    */
#include <os2.h>
#include <stdio.h>

int main(void) {
   HFILE  hfFileHandle    = 0L;          /* File Handle */
   ULONG  ulAction        = 0;           /* Action taken */
   UCHAR  uchFileName[20] = "test.dat";  /* File path name */
   APIRET rc              = NO_ERROR;    /* Return code */

   /* Create the file test.dat */

   rc = DosOpen(uchFileName,
                &hfFileHandle,
                &ulAction,
                10L,
                FILE_NORMAL,
                FILE_CREATE,
                OPEN_ACCESS_WRITEONLY | OPEN_SHARE_DENYNONE,
                0L);
   if (rc != NO_ERROR) {
      printf("DosOpen error: return code = %u\n", rc);
      return 1;
   } else {
     printf("DosOpen:   File created = %s\n", uchFileName);
   } /* endif */

   rc = DosClose(hfFileHandle);        /* Close the file */
   if (rc != NO_ERROR) {
     printf("DosClose error: return code = %u\n", rc);
     return 1;
   } /* endif */

   /* Delete file "test.dat" from current directory */

   rc = DosDelete(uchFileName);
   if(rc != NO_ERROR) {
     printf("DosDelete error: return code = %u\n", rc);
     return 1;
   } else {
     printf("DosDelete: File deleted = %s\n", uchFileName);
   } /* endif */

   return NO_ERROR;
}

Related Functions