void Q_mkdir (const char *path) { FILESTATUS3 fs; APIRET rc = DosCreateDir(path, NULL); if (rc == NO_ERROR) return; if ((DosQueryPathInfo(path, FIL_STANDARD, &fs, sizeof(fs)) == NO_ERROR) && (fs.attrFile & FILE_DIRECTORY)) { return; /* dir exists */ } COM_Error ("Unable to create directory %s", path); }
PRInt32 _PR_MD_MKDIR(const char *name, PRIntn mode) { PRInt32 rc; /* XXXMB - how to translate the "mode"??? */ if ((rc = DosCreateDir((char *)name, NULL))== NO_ERROR) { return 0; } else { _PR_MD_MAP_MKDIR_ERROR(rc); return -1; } }
BOOL CreatePath(char szPath[]) { int iIndex; int iLen; if (DosCreateDir(szPath,0) == NO_ERROR) return(TRUE); if ((iLen = strlen(szPath)) == 0) return(FALSE); for (iIndex = (iLen - 1);iIndex > 0;iIndex--) if (szPath[iIndex] =='\\') { szPath[iIndex] = 0; if (CreatePath(szPath)) { szPath[iIndex] = '\\'; if (DosCreateDir(szPath,0) == NO_ERROR) return(TRUE); } break; } return(FALSE); }
int main(VOID) { /* Create a file "first.dat" in the current directory */ rc = DosOpen("first.dat", &hfFileHandle, &ulAction, 100L, FILE_NORMAL, FILE_CREATE | OPEN_ACTION_OPEN_IF_EXISTS, OPEN_ACCESS_WRITEONLY | OPEN_SHARE_DENYNONE, 0L); if (rc != NO_ERROR) { printf("DosOpen error: return code = %u\n", rc); return 1; } rc = DosClose(hfFileHandle); /* Close the file (it contains junk) */ if (rc != NO_ERROR) { printf("DosClose error: return code = %u\n", rc); return 1; } /* Create a new subdirectory within the current directory */ rc = DosCreateDir(uchNewDirName, peaop2NewDirAttribute); if (rc != NO_ERROR) { printf("DosCreateDir error: return code = %u\n", rc); return 1; } /* Move the file "first.dat" from the current directory to the new directory "newdir", and rename it "second.dat" */ rc = DosMove(uchOldPathName, uchNewPathName); if (rc != NO_ERROR) { printf("DosMove error: return code = %u\n", rc); return 1; } else { printf("DosMove: Move from %s to %s complete.\n", uchOldPathName, uchNewPathName); } return NO_ERROR; }
/*@ XFile::CreateDirectory(const char *path) @group directorys @remarks Creates a directory @parameters char * path of the directory to create */ ULONG XFile::CreateDirectory(const char *path) { return DosCreateDir((PSZ) path, NULL); }
unsigned LocalMkDir( char *name ) /***************************/ { return( StashErrCode( DosCreateDir( name, NULL ), OP_LOCAL ) ); }
int __PHYSFS_platformMkDir(const char *path) { return(os2err(DosCreateDir(path, NULL)) == NO_ERROR); } /* __PHYSFS_platformMkDir */
static void *get_log_instance() { if (gLogInstance || gLogInstanceState == 2 || gInFork) return gLogInstance; /* Set a flag that we're going to init a new log instance */ if (!__atomic_cmpxchg32(&gLogInstanceState, 1, 0)) { /* * Another thread was faster in starting instance creation, wait for it * to complete in a simple spin loop (completion should be really quick). */ while (gLogInstanceState == 1) DosSleep(1); return gLogInstance; } void *logInstance = NULL; __LIBC_LOGGROUPS *logGroups = NULL; #if defined(TRACE_ENABLED) logGroups = &gLogGroups; __libc_LogGroupInit(&gLogGroups, "LIBCX_TRACE"); #endif /* Check if we are asked to log to console */ { PSZ dummy; gLogToConsole = DosScanEnv("LIBCX_TRACE_TO_CONSOLE", &dummy) == NO_ERROR; } char buf[CCHMAXPATH + 128]; if (gLogToConsole) { logInstance = __libc_LogInit(0, logGroups, "NUL"); if (logInstance) { /* * This is a dirty hack to write logs to stdout, * LIBC isn't capable of it on its own (@todo fix LIBC). */ typedef struct __libc_logInstance { /** Write Semaphore. */ HMTX hmtx; /** Filehandle. */ HFILE hFile; /** Api groups. */ __LIBC_PLOGGROUPS pGroups; } __LIBC_LOGINST, *__LIBC_PLOGINST; /* Sanity check (note: we use LIBC assert here to avoid recursion) */ assert(((__LIBC_PLOGINST)logInstance)->pGroups == logGroups); /* Duplicate STDOUT */ DosDupHandle(1, &((__LIBC_PLOGINST)logInstance)->hFile); } } else { /* * We don't query QSV_TIME_HIGH as it will remain 0 until 19-Jan-2038 and for * our purposes (generate an unique log name sorted by date) it's fine. */ ULONG time; DosQuerySysInfo(QSV_TIME_LOW, QSV_TIME_LOW, &time, sizeof(time)); // Get log directory (boot drive if no UNIXROOT) const char *path = "/var/log/libcx"; PSZ unixroot; if (DosScanEnv("UNIXROOT", &unixroot) != NO_ERROR) { ULONG drv; DosQuerySysInfo(QSV_BOOT_DRIVE, QSV_BOOT_DRIVE, &drv, sizeof(drv)); unixroot = "C:"; unixroot[0] = '@' + drv; path = ""; } else { /* * Make sure the directory exists (no error checks here as a failure to * do so will pop up later in __libc_LogInit anyway). */ if (strlen(unixroot) >= CCHMAXPATH) return NULL; strcpy(buf, unixroot); strcat(buf, path); DosCreateDir(buf, NULL); } // Get program name char name[CCHMAXPATH]; PPIB ppib = NULL; DosGetInfoBlocks(NULL, &ppib); if (DosQueryModuleName(ppib->pib_hmte, sizeof(name), name) != NO_ERROR) return NULL; _remext(name); logInstance = __libc_LogInit(0, logGroups, "%s%s/%s-%08lx-%04x.log", unixroot, path, _getname(name), time, getpid()); } /* Bail out if we failed to create a log file at all */ if (!logInstance) { gLogInstanceState = 0; return NULL; } if (!gLogToConsole) { // Write out LIBCx info strcpy(buf, "LIBCx version : " VERSION_MAJ_MIN_BLD LIBCX_DEBUG_SUFFIX LIBCX_DEV_SUFFIX "\n"); strcat(buf, "LIBCx module : "); APIRET arc = DosQueryModuleName(ghModule, CCHMAXPATH, buf + strlen(buf)); if (arc == NO_ERROR) sprintf(buf + strlen(buf), " (hmod=%04lx)\n", ghModule); else sprintf(buf + strlen(buf), " <error %ld>\n", arc); __libc_LogRaw(logInstance, __LIBC_LOG_MSGF_FLUSH, buf, strlen(buf)); } /* * Finish initialization by storing the instance and setting the state to 2 * (this will unfreeze other threads that started instance creation, if any). */ gLogInstance = logInstance; gLogInstanceState = 2; return gLogInstance; }
bool LocalInteractive( sys_handle fh ) /************************************/ { APIRET type; APIRET flags; //NYI: really should convert fh to sys_handle, but I know that it's // a one-to-one mapping #ifdef _M_I86 if( DosQHandType( fh, &type, &flags ) ) { #else if( DosQueryHType( fh, &type, &flags ) ) { #endif return( false ); } if( type == 1 ) { /* device type */ return( true ); } return( false ); } void LocalGetBuff( char *buff, unsigned size ) /********************************************/ { struct _STRINGINBUF length; if( size > UCHAR_MAX ) { size = UCHAR_MAX; } length.cb = size; length.cchIn = 0; if( KbdStringIn( buff, &length, 0, 0 ) ) { buff[0] = '\r'; buff[1] = NULLCHAR; return; } buff[length.cchIn] = NULLCHAR; } error_handle LocalRename( const char *from, const char *to ) /**********************************************************/ { #ifdef _M_I86 return( StashErrCode( DosMove( from, to, 0 ), OP_LOCAL ) ); #else return( StashErrCode( DosMove( from, to ), OP_LOCAL ) ); #endif } error_handle LocalMkDir( const char *name ) /*****************************************/ { #ifdef _M_I86 return( StashErrCode( DosMkDir( name, 0 ), OP_LOCAL ) ); #else return( StashErrCode( DosCreateDir( name, NULL ), OP_LOCAL ) ); #endif } error_handle LocalRmDir( const char *name ) /*****************************************/ { #ifdef _M_I86 return( StashErrCode( DosRmDir( name, 0 ), OP_LOCAL ) ); #else return( StashErrCode( DosDeleteDir( name ), OP_LOCAL ) ); #endif } error_handle LocalSetDrv( int drv ) /*********************************/ { #ifdef _M_I86 return( StashErrCode( DosSelectDisk( drv + 1 ), OP_LOCAL ) ); #else return( StashErrCode( DosSetDefaultDisk( drv + 1 ), OP_LOCAL ) ); #endif } int LocalGetDrv( void ) /*********************/ { APIRET drive; ULONG map; #ifdef _M_I86 if( DosQCurDisk( &drive, &map ) ) { #else if( DosQueryCurrentDisk( &drive, &map ) ) { #endif return( -1 ); } return( drive - 1 ); } error_handle LocalSetCWD( const char *name ) /******************************************/ { #ifdef _M_I86 return( StashErrCode( DosChDir( name, 0 ), OP_LOCAL ) ); #else return( StashErrCode( DosSetCurrentDir( name ), OP_LOCAL ) ); #endif } long LocalGetFileAttr( const char *name ) /***************************************/ { #ifdef _M_I86 USHORT attr; if( DosQFileMode( name, &attr, 0 ) ) { return( -1L ); } return( attr ); #else FILESTATUS3 fileinfo; if( DosQueryPathInfo( name, FIL_STANDARD, &fileinfo, sizeof( fileinfo ) ) ) { return( -1L ); } return( fileinfo.attrFile ); #endif }
//------------------------------ CMD_DosCreateDir ------------------------------ void CMD_DosCreateDir(HFILE hFile,LXIOCPA_DMN_CMDPARMPACKET* pParam ,PLXDOSCREATEDIRSTRUCT p) { pParam->rc=DosCreateDir(p->dirName,NULL); }