Jump to content

DosDeleteDir: Difference between revisions

From EDM2
Created page with "==Description== Removes a subdirectory from the specified disk. ==Syntax== <PRE> #define INCL_DOSFILEMGR #include <os2.h> PSZ pszDir; /* Address of the fully qualifi..."
 
Ak120 (talk | contribs)
mNo edit summary
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
==Description==
Removes a subdirectory from the specified disk.
Removes a subdirectory from the specified disk.


==Syntax==
==Syntax==
<PRE>
DosDeleteDir(pszDir)
#define INCL_DOSFILEMGR
#include <os2.h>


PSZ       pszDir;  /*  Address of the fully qualified path name of the subdirectory to be removed. */
==Parameters==
APIRET    ulrc;    /*  Return Code. */
;pszDir (PSZ) - input: Address of the fully qualified path name of the subdirectory to be removed.


ulrc = DosDeleteDir(pszDir);
</PRE>
==Parameters==
;  pszDir (PSZ) - input : Address of the fully qualified path name of the subdirectory to be removed.
==Return Code==
==Return Code==
ulrc (APIRET) - returns
;ulrc (APIRET) - returns:DosDeleteDir returns one of the following values:
*0 NO_ERROR
*2 ERROR_FILE_NOT_FOUND
*3 ERROR_PATH_NOT_FOUND
*5 ERROR_ACCESS_DENIED
*16 ERROR_CURRENT_DIRECTORY
*26 ERROR_NOT_DOS_DISK
*87 ERROR_INVALID_PARAMETER
*108 ERROR_DRIVE_LOCKED
*206 ERROR_FILENAME_EXCED_RANGE


DosDeleteDir returns one of the following values:
* 0    NO_ERROR
* 2        ERROR_FILE_NOT_FOUND
* 3        ERROR_PATH_NOT_FOUND
* 5        ERROR_ACCESS_DENIED
* 16        ERROR_CURRENT_DIRECTORY
* 26        ERROR_NOT_DOS_DISK
* 87        ERROR_INVALID_PARAMETER
* 108        ERROR_DRIVE_LOCKED
* 206        ERROR_FILENAME_EXCED_RANGE
==Remarks==
==Remarks==
The subdirectory must be empty; that is, it cannot have hidden files or directory entries other than the "." and ".." entries. To delete files, use DosDelete or DosForceDelete.
The subdirectory must be empty; that is, it cannot have hidden files or directory entries other than the "." and ".." entries. To delete files, use [[DosDelete]] or [[DosForceDelete]].


The root directory and current directory cannot be removed.  
The root directory and current directory cannot be removed.


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


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


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

Latest revision as of 09:45, 28 January 2018

Removes a subdirectory from the specified disk.

Syntax

DosDeleteDir(pszDir)

Parameters

pszDir (PSZ) - input
Address of the fully qualified path name of the subdirectory to be removed.

Return Code

ulrc (APIRET) - returns
DosDeleteDir returns one of the following values:
  • 0 NO_ERROR
  • 2 ERROR_FILE_NOT_FOUND
  • 3 ERROR_PATH_NOT_FOUND
  • 5 ERROR_ACCESS_DENIED
  • 16 ERROR_CURRENT_DIRECTORY
  • 26 ERROR_NOT_DOS_DISK
  • 87 ERROR_INVALID_PARAMETER
  • 108 ERROR_DRIVE_LOCKED
  • 206 ERROR_FILENAME_EXCED_RANGE

Remarks

The subdirectory must be empty; that is, it cannot have hidden files or directory entries other than the "." and ".." entries. To delete files, use DosDelete or DosForceDelete.

The root directory and current directory cannot be removed.

Example Code

This example creates, accesses, and finally deletes a new directory, named "TEMPPROG", from the root directory. Some return codes are not checked for brevity.

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

int main(VOID) {
   UCHAR   achOrigDirName[256] = "";            /* Original directory name  */
   UCHAR   achNewDirName[256]  = "\\TEMPPROG";  /* New directory to create  */
   UCHAR   achDirName[256]     = "";          /* Directory name for queries */
   ULONG   cbDirPathLen    = 0;               /* Length of directory path   */
   PEAOP2  pEABuf       = NULL;   /* Extended Attribute buffer pointer      */
   ULONG   ulDriveNum   = 0;      /* Drive number: current=0, A=1, B=2, ... */
   APIRET  rc           = NO_ERROR;      /* Return code                     */

   cbDirPathLen = (ULONG) sizeof(achOrigDirName);
   rc = DosQueryCurrentDir(ulDriveNum, achOrigDirName, &cbDirPathLen);

   if (rc != NO_ERROR) {
      printf("DosQueryCurrentDir error: return code = %u\n", rc);
      return 1;
   } else printf ("Original dir. = \\%s\n", achOrigDirName);

   pEABuf = NULL;  /* Indicate no EAs are to be defined for the directory  */
   rc = DosCreateDir(achNewDirName, pEABuf);   /* Create the new directory */

   if (rc != NO_ERROR) {
      printf("DosCreateDir error: return code = %u\n", rc);
      return 1;
   }

   rc = DosSetCurrentDir (achNewDirName);   /* Change to new directory     */

   ulDriveNum = 0;
   cbDirPathLen = (ULONG) sizeof(achDirName);
   rc = DosQueryCurrentDir(ulDriveNum, achDirName, &cbDirPathLen);

   if (rc != NO_ERROR) {
      printf("DosQueryCurrentDir error: return code = %u\n", rc);
      return 1;
   } else printf ("Current dir.  = \\%s\n", achDirName);

   strcpy(achDirName,"\\");

   rc = DosSetCurrentDir (achDirName);     /* Change to root directory     */
   rc = DosDeleteDir (achNewDirName);      /* Delete the new directory     */

   return NO_ERROR;
}

Related Functions