예제 #1
0
int chdir_cmd(int argc, char **argv)
{
  UCHAR   achDirName[256]     = "";          /* Directory name for queries */
  ULONG   cbDirPathLen    = 0;               /* Length of directory path   */
  APIRET  rc           = NO_ERROR;      /* Return code                     */
  UCHAR   chDisk;
  ULONG   ulDriveNum   = 0;      /* Drive number (A=1, B=2, C=3, ...)    */
  ULONG   ulDriveMap   = 0;      /* Mapping of valid drives              */
  ULONG   i            = 0;      /* A loop index                         */

  if (argc==1)
  {
  rc = DosQueryCurrentDisk (&ulDriveNum, &ulDriveMap);
  chDisk=(UCHAR)(ulDriveNum+'A'-1);

  cbDirPathLen = 0;
  rc = DosQueryCurrentDir(0, achDirName, &cbDirPathLen);
  rc = DosQueryCurrentDir(0, achDirName, &cbDirPathLen);

  VioWrtTTY(&chDisk, 1, 0);
  VioWrtTTY(":\\", 2, 0);
  VioWrtTTY(achDirName, cbDirPathLen-1, 0);
  VioWrtTTY("\n\r", 2, 0);
  } else {
    DosSetCurrentDir(argv[1]);
  };


  return 0;
}
예제 #2
0
BOOL DoCheckDisk(BOOL fDoCheck)
{
ULONG ulCurDisk;
USHORT usIndex;
ULONG ulDummy;

      DosQueryCurrentDisk(&ulCurDisk, &ulDummy);
      ulDriveMap = GetFAT32Drives();

      for (usIndex = 0; usIndex < 26; usIndex++)
         {
         ULONG Mask = 0x0001 << usIndex;
         BYTE szDisk[3];

         if (!(ulDriveMap & Mask))
            continue;
         szDisk[0] = (BYTE)('A' + usIndex);
         szDisk[1] = ':';
         szDisk[2] = 0;

         if (!IsDiskClean(szDisk) && fDoCheck)
            if (!ChkDsk(ulCurDisk, szDisk))
               return FALSE;
         }

      return TRUE;
}
예제 #3
0
파일: os_os2.c 프로젝트: soubok/libset
/*
** Turn a relative pathname into a full pathname.  Write the full
** pathname into zFull[].  zFull[] will be at least pVfs->mxPathname
** bytes in size.
*/
static int os2FullPathname(
  sqlite3_vfs *pVfs,          /* Pointer to vfs object */
  const char *zRelative,      /* Possibly relative input path */
  int nFull,                  /* Size of output buffer in bytes */
  char *zFull                 /* Output buffer */
){
  if( strchr(zRelative, ':') ){
    sqlite3SetString( &zFull, zRelative, (char*)0 );
  }else{
    ULONG ulDriveNum = 0;
    ULONG ulDriveMap = 0;
    ULONG cbzBufLen = SQLITE_TEMPNAME_SIZE;
    char zDrive[2];
    char *zBuff = (char*)malloc( cbzBufLen );
    if( zBuff == 0 ){
      return SQLITE_NOMEM;
    }
    DosQueryCurrentDisk( &ulDriveNum, &ulDriveMap );
    if( DosQueryCurrentDir( ulDriveNum, (PBYTE)zBuff, &cbzBufLen ) == NO_ERROR ){
      sprintf( zDrive, "%c", (char)('A' + ulDriveNum - 1) );
      sqlite3SetString( &zFull, zDrive, ":\\", zBuff,
                        "\\", zRelative, (char*)0 );
    }
    free( zBuff );
  }
  return SQLITE_OK;
}
예제 #4
0
파일: os_os2.c 프로젝트: soubok/libset
/*
** Create a temporary file name in zBuf.  zBuf must be big enough to
** hold at pVfs->mxPathname characters.
*/
static int os2GetTempname( sqlite3_vfs *pVfs, int nBuf, char *zBuf ){
  static const unsigned char zChars[] =
    "abcdefghijklmnopqrstuvwxyz"
    "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    "0123456789";
  int i, j;
  PSZ zTempPath = "";
  if( DosScanEnv( (PSZ)"TEMP", &zTempPath ) ){
    if( DosScanEnv( (PSZ)"TMP", &zTempPath ) ){
      if( DosScanEnv( (PSZ)"TMPDIR", &zTempPath ) ){
           ULONG ulDriveNum = 0, ulDriveMap = 0;
           DosQueryCurrentDisk( &ulDriveNum, &ulDriveMap );
           sprintf( (char*)zTempPath, "%c:", (char)( 'A' + ulDriveNum - 1 ) );
      }
    }
  }
  /* strip off a trailing slashes or backslashes, otherwise we would get *
   * multiple (back)slashes which causes DosOpen() to fail               */
  j = strlen(zTempPath);
  while( j > 0 && ( zTempPath[j-1] == '\\' || zTempPath[j-1] == '/' ) ){
    j--;
  }
  zTempPath[j] = '\0';
  assert( nBuf>=pVfs->mxPathname );
  sqlite3_snprintf( pVfs->mxPathname-30, zBuf,
                    "%s\\"SQLITE_TEMP_FILE_PREFIX, zTempPath );
  j = strlen( zBuf );
  sqlite3Randomness( 20, &zBuf[j] );
  for( i = 0; i < 20; i++, j++ ){
    zBuf[j] = (char)zChars[ ((unsigned char)zBuf[j])%(sizeof(zChars)-1) ];
  }
  zBuf[j] = 0;
  OSTRACE2( "TEMP FILENAME: %s\n", zBuf );
  return SQLITE_OK;
}
예제 #5
0
/*@ XFile::GetCurrentDisk(char &buffer)
@group disks
@remarks Query the current disk
@parameters char&  buffer to hold data (will contain A,B,..)
*/
void XFile::GetCurrentDisk(char &buffer)
{
   ULONG u1, u2;

   DosQueryCurrentDisk(&u1, &u2);
   buffer = (char) u1 + 'A' - 1;
}
예제 #6
0
파일: filesys.c 프로젝트: ohmann/checkapi
APR_DECLARE(apr_status_t) apr_filepath_get(char **defpath, apr_int32_t flags,
                                           apr_pool_t *p)
{
    char path[APR_PATH_MAX];
    ULONG drive;
    ULONG drivemap;
    ULONG rv, pathlen = sizeof(path) - 3;
    char *pos;

    DosQueryCurrentDisk(&drive, &drivemap);
    path[0] = '@' + drive;
    strcpy(path+1, ":\\");
    rv = DosQueryCurrentDir(drive, path+3, &pathlen);

    *defpath = apr_pstrdup(p, path);

    if (!(flags & APR_FILEPATH_NATIVE)) {
        for (pos=*defpath; *pos; pos++) {
            if (*pos == '\\')
                *pos = '/';
        }
    }

    return APR_SUCCESS;
}
예제 #7
0
파일: os_os2.c 프로젝트: 3rdexp/jezzitest
/*
** Create a temporary file name in zBuf.  zBuf must be big enough to
** hold at least SQLITE_TEMPNAME_SIZE characters.
*/
int sqlite3Os2TempFileName( char *zBuf ){
  static const unsigned char zChars[] =
    "abcdefghijklmnopqrstuvwxyz"
    "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    "0123456789";
  int i, j;
  PSZ zTempPath = 0;
  if( DosScanEnv( (PSZ)"TEMP", &zTempPath ) ){
    if( DosScanEnv( (PSZ)"TMP", &zTempPath ) ){
      if( DosScanEnv( (PSZ)"TMPDIR", &zTempPath ) ){
           ULONG ulDriveNum = 0, ulDriveMap = 0;
           DosQueryCurrentDisk( &ulDriveNum, &ulDriveMap );
           sprintf( (char*)zTempPath, "%c:", (char)( 'A' + ulDriveNum - 1 ) );
      }
    }
  }
  for(;;){
      sprintf( zBuf, "%s\\"TEMP_FILE_PREFIX, zTempPath );
      j = strlen( zBuf );
      sqlite3Randomness( 15, &zBuf[j] );
      for( i = 0; i < 15; i++, j++ ){
        zBuf[j] = (char)zChars[ ((unsigned char)zBuf[j])%(sizeof(zChars)-1) ];
      }
      zBuf[j] = 0;
      if( !sqlite3OsFileExists( zBuf ) ) break;
  }
  OSTRACE2( "TEMP FILENAME: %s\n", zBuf );
  return SQLITE_OK;
}
예제 #8
0
파일: os2.c 프로젝트: UIKit0/paragui
char *__PHYSFS_platformCurrentDir(void)
{
    char *retval;
    ULONG currentDisk;
    ULONG dummy;
    ULONG pathSize = 0;
    APIRET rc;
    BYTE byte;

    rc = DosQueryCurrentDisk(&currentDisk, &dummy);
    BAIL_IF_MACRO(os2err(rc) != NO_ERROR, NULL, NULL);

    /* The first call just tells us how much space we need for the string. */
    rc = DosQueryCurrentDir(currentDisk, &byte, &pathSize);
    pathSize++; /* Add space for null terminator. */
    retval = (char *) malloc(pathSize + 3);  /* plus "x:\\" */
    BAIL_IF_MACRO(retval == NULL, ERR_OUT_OF_MEMORY, NULL);

    /* Actually get the string this time. */
    rc = DosQueryCurrentDir(currentDisk, (PBYTE) (retval + 3), &pathSize);
    if (os2err(rc) != NO_ERROR)
    {
        free(retval);
        return(NULL);
    } /* if */

    retval[0] = ('A' + (currentDisk - 1));
    retval[1] = ':';
    retval[2] = '\\';
    return(retval);
} /* __PHYSFS_platformCurrentDir */
예제 #9
0
파일: posix-fs.cpp 프로젝트: 86400/scummvm
bool POSIXFilesystemNode::getChildren(AbstractFSList &myList, ListMode mode, bool hidden) const {
	assert(_isDirectory);

#ifdef __OS2__
	if (_path == "/") {
		// Special case for the root dir: List all DOS drives
		ULONG ulDrvNum;
		ULONG ulDrvMap;

		DosQueryCurrentDisk(&ulDrvNum, &ulDrvMap);

		for (int i = 0; i < 26; i++) {
			if (ulDrvMap & 1) {
				char drive_root[] = "A:/";
				drive_root[0] += i;

                POSIXFilesystemNode *entry = new POSIXFilesystemNode();
				entry->_isDirectory = true;
				entry->_isValid = true;
				entry->_path = drive_root;
				entry->_displayName = "[" + Common::String(drive_root, 2) + "]";
				myList.push_back(entry);
			}

			ulDrvMap >>= 1;
		}

		return true;
	}
예제 #10
0
/*@ XFile::IsDriveAvaible(const char drive)
@group disks
@remarks Query if a drive is avaible or not
@parameters char drive     the drive (A, B, ....)
@returns    BOOL result
*/
BOOL XFile::IsDriveAvaible(const char drive)
{
   SHORT number = drive - 'A';
   ULONG u1 = 0, u2 = 0;

   DosQueryCurrentDisk(&u1, &u2);
   return ((u2 << (31 - number) >> 31) ? TRUE : FALSE);
}
int main(int argc, char *argv[]) { APIRET rc;
  rc =DosQueryCurrentDisk( &CurDriveNo, &DriveMap ); if(rc) { fprintf(stderr,"error %lu on DosQueryCurrentDisk\n",rc); return rc; }

  //rc = drvPath(&path,&pathmaxlen, CurDriveNo );
  //printf("%c:%c%s\n", drvBst(CurDriveNo), rc ? ' ' : PathSep, path );

  allDrivePaths(showlocal);

  return 0;
}
예제 #12
0
/*
 * Return first char of filesystem type, or 0 if unknown.
 */
static char
getFSType(const char *path)
{
    static char cache[1 + 26];
    char drive[3], info[512];
    Word unit, infolen;
    char r;

    if (isalpha(path[0]) && path[1] == ':') {
        unit = toupper(path[0]) - '@';
        path += 2;
    }
    else {
        ULONG driveMap;
#if OS2 >= 2
        if (DosQueryCurrentDisk(&unit, &driveMap))
#else
        if (DosQCurDisk(&unit, &driveMap))
#endif
            return 0;
    }

    if ((path[0] == '\\' || path[0] == '/') &&
        (path[1] == '\\' || path[1] == '/'))
        return 0;

    if (cache[unit])
        return cache[unit];

    drive[0] = '@' + unit;
    drive[1] = ':';
    drive[2] = '\0';
    infolen = sizeof info;
#if OS2 >= 2
    if (DosQueryFSAttach(drive, 0, FSAIL_QUERYNAME, (PVOID)info, &infolen))
        return 0;
    if (infolen >= sizeof(FSQBUFFER2)) {
        FSQBUFFER2 *p = (FSQBUFFER2 *)info;
        r = p->szFSDName[p->cbName];
    }
    else
#else
    if (DosQFSAttach((PSZ)drive, 0, FSAIL_QUERYNAME, (PVOID)info, &infolen, 0))
        return 0;
    if (infolen >= 9) {
        char *p = info + sizeof(USHORT);
        p += sizeof(USHORT) + *(USHORT *)p + 1 + sizeof(USHORT);
        r = *p;
    }
    else
#endif
        r = 0;
    return cache[unit] = r;
}
예제 #13
0
int LocalGetDrv( void )
/*********************/
{
    ULONG drive;
    ULONG map;

    if( DosQueryCurrentDisk( &drive, &map ) ) {
        return( -1 );
    }
    return( drive - 1 );
}
예제 #14
0
int queryCurrentDisk()
{
	int   drive;
	ULONG driveNo, driveMap;

	if (DosQueryCurrentDisk(&driveNo, &driveMap) == 0)
		{
		drive = (driveNo-1) + 'A';
		}

	return drive;
}
예제 #15
0
BOOL fillDrvList(PINSTALLDATA pid, HWND hprgs) {
   char dev[4];
   FSALLOCATE fsa;
   BYTE buf[32];
   CHAR achdd[32];
   ULONG ulDriveNum = 0;
   ULONG ulDriveMap = 0;
   ULONG ul, idx, tot;
   int i, j, k;
   PFSQBUFFER2 pfsqb = (PFSQBUFFER2)buf;

   strcpy(dev, " :");
   DosError(0);
   DosQueryCurrentDisk(&ulDriveNum, &ulDriveMap);
   // conta drive presenti
   for (i = 2, tot = 0; i < 26; ++i)
      tot += (ulDriveMap & 1L << i)? 1: 0;
   // per ogni drive presente raccogli informazioni
   for (i = 2, j = 0, k = 0, idx = 0; i < 26; i++) {// ripete x tutti i drive
//      DosSleep(1000);
      if (ulDriveMap & 1L << i) {            // se trova partizione
         if (Wincrease(&idx, hprgs, tot)) return FALSE;
         ul = 32;
         dev[0] = (CHAR)(i + 'A');
         if (DosQueryFSInfo(i + 1, FSIL_ALLOC, &fsa, sizeof(FSALLOCATE)))
            continue;        // se drive non disponibile passa a successivo
         DosQueryFSAttach((PSZ)dev, 1, FSAIL_QUERYNAME,
                          (PFSQBUFFER2)&buf, &ul);
         if (pfsqb->iType != 3 ||         // se non drive locale
             (strcmp(pfsqb->szName + 3, "FAT") &&    // o nŠ FAT
              strcmp(pfsqb->szName + 3, "HPFS") &&
              strcmp(pfsqb->szName + 3, "JFS")))    // e nŠ HPFS
            continue;                     // passa al successivo
         pid->cMbDrv[i] = (ULONG)((float)fsa.cbSector *
                                  (float)fsa.cSectorUnit *
                                  (float)fsa.cUnitAvail)
                                  / 1048576;
         sprintf(achdd, "%s % 15d MB", dev, pid->cMbDrv[i]);
         DlgLboxInsertItem(pid->hwnd, LBX_INSTDRV, LIT_END, achdd);
         // seleziona l'item corrispondente al drive menzionato in pad->path
         if (dev[0] == *pid->tpath) k = j;
         j++;
      } // end if
   } // end for
   Wincrease(&idx, hprgs, tot);
   DosError(1);
   DlgLboxSelectItem(pid->hwnd, LBX_INSTDRV, k);
   WinPostMsg(hprgs, PRGSM_END, MPVOID, MPVOID);
   return TRUE;
}
예제 #16
0
/*
** Create a temporary file name in zBuf.  zBuf must be big enough to
** hold at pVfs->mxPathname characters.
*/
static int getTempname(int nBuf, char *zBuf ){
  static const unsigned char zChars[] =
    "abcdefghijklmnopqrstuvwxyz"
    "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    "0123456789";
  int i, j;
  char zTempPathBuf[3];
  PSZ zTempPath = (PSZ)&zTempPathBuf;
  if( sqlite3_temp_directory ){
    zTempPath = sqlite3_temp_directory;
  }else{
    if( DosScanEnv( (PSZ)"TEMP", &zTempPath ) ){
      if( DosScanEnv( (PSZ)"TMP", &zTempPath ) ){
        if( DosScanEnv( (PSZ)"TMPDIR", &zTempPath ) ){
           ULONG ulDriveNum = 0, ulDriveMap = 0;
           DosQueryCurrentDisk( &ulDriveNum, &ulDriveMap );
           sprintf( (char*)zTempPath, "%c:", (char)( 'A' + ulDriveNum - 1 ) );
        }
      }
    }
  }
  /* Strip off a trailing slashes or backslashes, otherwise we would get *
   * multiple (back)slashes which causes DosOpen() to fail.              *
   * Trailing spaces are not allowed, either.                            */
  j = sqlite3Strlen30(zTempPath);
  while( j > 0 && ( zTempPath[j-1] == '\\' || zTempPath[j-1] == '/'
                    || zTempPath[j-1] == ' ' ) ){
    j--;
  }
  zTempPath[j] = '\0';
  if( !sqlite3_temp_directory ){
    char *zTempPathUTF = convertCpPathToUtf8( zTempPath );
    sqlite3_snprintf( nBuf-30, zBuf,
                      "%s\\"SQLITE_TEMP_FILE_PREFIX, zTempPathUTF );
    free( zTempPathUTF );
  }else{
    sqlite3_snprintf( nBuf-30, zBuf,
                      "%s\\"SQLITE_TEMP_FILE_PREFIX, zTempPath );
  }
  j = sqlite3Strlen30( zBuf );
  sqlite3_randomness( 20, &zBuf[j] );
  for( i = 0; i < 20; i++, j++ ){
    zBuf[j] = (char)zChars[ ((unsigned char)zBuf[j])%(sizeof(zChars)-1) ];
  }
  zBuf[j] = 0;
  OSTRACE2( "TEMP FILENAME: %s\n", zBuf );
  return SQLITE_OK;
}
예제 #17
0
VOID FillDriveList(HWND hwnd, PATTMAN pam) {
   CHAR   szDrive[] = "[ ]";
   ULONG  ulDriveNum = 0   ;
   ULONG  ulDriveMap = 0   ;
   SHORT  i          = 0   ;

   DosQueryCurrentDisk(&ulDriveNum, &ulDriveMap);
   for (i = 0; i < 26; i++) {
      if (ulDriveMap & 1L << i) {
         szDrive[1] = (CHAR)(i + 'A');
         DlgLboxInsertItem(hwnd, LB_DRIVE, LIT_END, szDrive);
      } /* endif */
   } /* endfor */
   pam->fsp.sPrvDrv = ulDriveNum - 1;
   MyDlgLboxSelectItem(hwnd, LB_DRIVE, pam->fsp.sPrvDrv);
}
예제 #18
0
VOID FillDirListBox (HWND hwnd, CHAR *pcCurrentPath)
     {
     static CHAR  szDrive [] = "  :" ;
     FILEFINDBUF3 findbuf ;
     HDIR         hDir = HDIR_CREATE ;
     SHORT        sDrive ;
     ULONG        ulDriveNum, ulDriveMap, ulCurPathLen,
                  ulReturn, ulSearchCount = 1 ;

     DosQueryCurrentDisk (&ulDriveNum, &ulDriveMap) ;
     pcCurrentPath [0] = (CHAR) ulDriveNum + '@' ;
     pcCurrentPath [1] = ':' ;
     pcCurrentPath [2] = '\\' ;

     ulCurPathLen = CCHMAXPATH ;
     DosQueryCurrentDir (0, pcCurrentPath + 3, &ulCurPathLen) ;

     WinSetDlgItemText (hwnd, IDD_PATH, pcCurrentPath) ;
     WinSendDlgItemMsg (hwnd, IDD_DIRLIST, LM_DELETEALL, NULL, NULL) ;

     for (sDrive = 0 ; sDrive < 26 ; sDrive++)
          if (ulDriveMap & 1L << sDrive)
               {
               szDrive [1] = (CHAR) sDrive + 'A' ;

               WinSendDlgItemMsg (hwnd, IDD_DIRLIST, LM_INSERTITEM,
                                  MPFROM2SHORT (LIT_END, 0),
                                  MPFROMP (szDrive)) ;
               }

     ulReturn = DosFindFirst ("*.*", &hDir, FILE_DIRECTORY, &findbuf,
                              sizeof findbuf, &ulSearchCount, FIL_STANDARD) ;
     while (!ulReturn)
          {
          if (findbuf.attrFile & 0x0010 &&
                    (findbuf.achName [0] != '.' || findbuf.achName [1]))
               
               WinSendDlgItemMsg (hwnd, IDD_DIRLIST, LM_INSERTITEM,
                                  MPFROM2SHORT (LIT_SORTASCENDING, 0),
                                  MPFROMP (findbuf.achName)) ;

          ulReturn = DosFindNext (hDir, &findbuf, sizeof findbuf,
                                  &ulSearchCount) ;
          }

     DosFindClose (hDir) ;
     }
예제 #19
0
/* --------------------------------------------------------------------------
 Return the amount of available space on a disk volume.
- Parameters -------------------------------------------------------------
 PSZ pszPath : path to be queried for the amount of free space.
- Return value -----------------------------------------------------------
 LONGLONG amount of available free space (-1 in case of error).
-------------------------------------------------------------------------- */
LONGLONG fmAvailSpace(PSZ pszPath, PULONG pCbSector) {
   FSALLOCATE fsa;
   ULONG ulDrvNum, ulDrvMap;

   if (!pszPath || (pszPath[1] != ':'))
      DosQueryCurrentDisk(&ulDrvNum, &ulDrvMap);
   else
      ulDrvNum = *pszPath & ~0x20 - 'A' + 1;
   g.rc = DosQueryFSInfo(ulDrvNum, FSIL_ALLOC, &fsa, sizeof(fsa));
   if (g.rc)
   {
      handleError(FALSE, FALSE, SZERR_QUERYFREESPACE, ulDrvNum + 'A' - 1, g.rc);
      return -1LL;
   }
   if (pCbSector) *pCbSector = fsa.cbSector;
   return   (LONGLONG)fsa.cbSector * (LONGLONG)fsa.cSectorUnit
          * (LONGLONG)fsa.cUnitAvail;
}
예제 #20
0
void Q_getwd (char *out, size_t size, qboolean trailing_dirsep)
{
	ULONG l, drv;

	if (size < 8) COM_Error ("Too small buffer for getcwd");
	l = size - 3;
	if (DosQueryCurrentDir(0, (PBYTE) out + 3, &l) != NO_ERROR)
		COM_Error ("Couldn't determine current directory");
	DosQueryCurrentDisk(&drv, &l);
	out[0] = drv + 'A' - 1;
	out[1] = ':';
	out[2] = '\\';

	if (!trailing_dirsep)
		return;
	l = strlen(out);
	if (out[l - 1] == '\\' || out[l - 1] == '/')
		return;
	qerr_strlcat(__thisfunc__, __LINE__, out, "\\", size);
}
예제 #21
0
const char *osd_get_volume_name(int idx)
{
    static char szDrive[] = "A:\\";

    ULONG ulCurDisk;
    ULONG ulDriveMap;

    DosQueryCurrentDisk(&ulCurDisk, &ulDriveMap);

    szDrive[ 0 ] = 'A';
    while(idx--) {
        do
        {
            ulDriveMap >>= 1;
            szDrive[ 0 ]++;
        } while(ulDriveMap && (ulDriveMap & 1) == 0);
        if (!ulDriveMap) return NULL;
    }

    return szDrive;
}
예제 #22
0
ULONG GetFAT32Drives(VOID)
{
USHORT usIndex;
ULONG ulCurDisk;

   if (ulDriveMap)
      return ulDriveMap;

   if (DosQueryCurrentDisk(&ulCurDisk, &ulDriveMap))
      {
      ulDriveMap = 0L;
      return 0L;
      }

   for (usIndex = 0; usIndex < 26; usIndex++)
      {
      ULONG Mask = 1L << usIndex;
      BYTE szDisk[3];

      if (!(ulDriveMap & Mask))
         continue;

      /*
         Skip A: and B:
      */

      if (usIndex < 2)
         {
         ulDriveMap &= ~Mask;
         continue;
         }

      szDisk[0] = (BYTE)('A' + usIndex);
      szDisk[1] = ':';
      szDisk[2] = 0;
      if (!IsDiskFat32(szDisk))
         ulDriveMap &= ~Mask;
      }
   return ulDriveMap;
}
예제 #23
0
Struktur::Struktur (unsigned long id, IWindow *o) :
        IContainerControl (id, o, o)
{
        showTreeIconView ();
        unsigned long current, mask;
        DosQueryCurrentDisk (&current, &mask);
        unsigned long n = 0;
        for ( unsigned int bit = 1; n < 26; bit <<= 1, ++n )
        {
                if ( mask & bit )
                {
                        Verzeichnis *root = new Verzeichnis (IString ((char)('A' + n)) + ":");
                        if ( current == (n + 1) )
                                Aktiv = root;
                        addObject (root);
                        addObject (new Verzeichnis ("dummy"), root);
                }
        }
        IDMHandler::defaultTargetHandler ().handleEventsFor (this);
        IDMHandler::defaultTargetHandler ().enableDropOn (this);
        setItemProvider (this);
}
예제 #24
0
void showpath(void)
{
  UCHAR   chDisk;
  UCHAR   achDirName[256]     = "";          /* Directory name for queries */
  ULONG   cbDirPathLen    = 0;               /* Length of directory path   */
  APIRET  rc           = NO_ERROR;      /* Return code                     */
  ULONG   ulDriveNum   = 0;      /* Drive number (A=1, B=2, C=3, ...)    */
  ULONG   ulDriveMap   = 0;      /* Mapping of valid drives              */
  ULONG   i            = 0;      /* A loop index                         */

  rc = DosQueryCurrentDisk (&ulDriveNum, &ulDriveMap);
  chDisk=(UCHAR)(ulDriveNum+'A'-1);

  cbDirPathLen = 0;
  rc = DosQueryCurrentDir(0, achDirName, &cbDirPathLen);
  rc = DosQueryCurrentDir(0, achDirName, &cbDirPathLen);

  VioWrtTTY("[", 1, 0);
  VioWrtTTY(&chDisk, 1, 0);
  VioWrtTTY(":\\", 2, 0);
  VioWrtTTY(achDirName, cbDirPathLen-1, 0);
  VioWrtTTY("]", 1, 0);
}
예제 #25
0
/*
** Create a temporary file name in zBuf.  zBuf must be big enough to
** hold at least SQLITE_TEMPNAME_SIZE characters.
*/
int sqlite3Os2TempFileName( char *zBuf ){
  static const unsigned char zChars[] =
    "abcdefghijklmnopqrstuvwxyz"
    "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    "0123456789";
  int i, j;
  PSZ zTempPath = 0;
  if( DosScanEnv( (PSZ)"TEMP", &zTempPath ) ){
    if( DosScanEnv( (PSZ)"TMP", &zTempPath ) ){
      if( DosScanEnv( (PSZ)"TMPDIR", &zTempPath ) ){
           ULONG ulDriveNum = 0, ulDriveMap = 0;
           DosQueryCurrentDisk( &ulDriveNum, &ulDriveMap );
           sprintf( (char*)zTempPath, "%c:", (char)( 'A' + ulDriveNum - 1 ) );
      }
    }
  }
  /* strip off a trailing slashes or backslashes, otherwise we would get *
   * multiple (back)slashes which causes DosOpen() to fail               */
  j = strlen(zTempPath);
  while( j > 0 && zTempPath[j-1] == '\\' || zTempPath[j-1] == '/' ){
      j--;
  }
  zTempPath[j] = '\0';
  for(;;){
      sprintf( zBuf, "%s\\"TEMP_FILE_PREFIX, zTempPath );
      j = strlen( zBuf );
      sqlite3Randomness( 15, &zBuf[j] );
      for( i = 0; i < 15; i++, j++ ){
        zBuf[j] = (char)zChars[ ((unsigned char)zBuf[j])%(sizeof(zChars)-1) ];
      }
      zBuf[j] = 0;
      if( !sqlite3OsFileExists( zBuf ) ) break;
  }
  OSTRACE2( "TEMP FILENAME: %s\n", zBuf );
  return SQLITE_OK;
}
VOID StartInstallerThread( ULONG Action )
{
 // Если поток уже работает - возврат.
 if( Installer_Thread.Processing ) return;

 // Запоминаем, что надо сделать.
 bzero( &Installer_Thread, sizeof( Installer_Thread ) );

 if( Action == NIA_INSTALL )
  {
   Installer_Thread.Install_Enhancer = 1;
  }
 else
  {
   Installer_Thread.Uninstall_Enhancer = 1;
  }

 // Узнаем рабочий каталог.
 {
  ULONG Current_drive = 0; ULONG Drive_map = 0; ULONG Length = SIZE_OF_PATH - 3;
  DosQueryCurrentDisk( &Current_drive, &Drive_map );
  Installer_Thread.Current_directory[ 0 ] = (CHAR) Current_drive + 64;
  Installer_Thread.Current_directory[ 1 ] = ':';
  Installer_Thread.Current_directory[ 2 ] = '\\';
  DosQueryCurrentDir( 0, &Installer_Thread.Current_directory[ 3 ], &Length );
 }

 // Создаем поток.
 DosCreateThread( &Installer_Thread.Installer, (PFNTHREAD) Installer_InstallerThread, 0, 0, 32768 );

 // Запоминаем, что он работает.
 Installer_Thread.Processing = 1;

 // Возврат.
 return;
}
int main (int argc, char *argv[])
{
  char logText[CCHMAXPATH];
  short a;
  FILE *file;
  ULONG fl;
  HWND hwndClient;
  char text[CCHMAXPATH+10];
  char title[CCHMAXPATH];

  /* Create a copy of the args */
  /* argv[0]: progname
   * argv[1]: installdir of Audio-CD-Creator
   * argv[2]: foldername
   * argv[3]: imagename
   * argv[4]: Parameter file
   */
  ULONG ulDriveNum=0;
  ULONG ulDriveMap=0;
  APIRET rc;
  int i;

  rc=DosQueryCurrentDisk(&ulDriveNum, &ulDriveMap);
  if(rc!=NO_ERROR) {
    printf("Error\n");
    exit(1);
  }
  printf("Current disk: %c:\n",'A'+ulDriveNum-1);
  printf("Drive map:\n");
  printf("A B C D E F G H I J K L M N O P Q R S T U V W X Y Z\n");

  for(i=0;i<26;i++) {
    printf(( (ulDriveMap << (31-i)) >>31) ? "y ": "- ");
  }
  printf("\n\n");

  DosError(FERR_DISABLEHARDERR);
  for(i=2;i<26;i++) {
    if(( (ulDriveMap << (31-i)) >>31)) {
      char chrDrive[3]="A:";
      BYTE fsqBuf2[sizeof(FSQBUFFER2)+3*CCHMAXPATH]={0};
      PFSQBUFFER2 pfsqBuf2=(PFSQBUFFER2) &fsqBuf2;
      ULONG ulLength;
      /* Get FS */
      chrDrive[0]='A'+i;
      ulLength=sizeof(fsqBuf2);
      rc=DosQueryFSAttach(chrDrive,0L,FSAIL_QUERYNAME, (PFSQBUFFER2)&fsqBuf2, &ulLength);
      if(DosQueryFSAttach(chrDrive,0L,FSAIL_QUERYNAME, (PFSQBUFFER2)&fsqBuf2, &ulLength)==NO_ERROR) {
        if(!strcmp(pfsqBuf2->szName+pfsqBuf2->cbName+1,"ISOFS")) {
          FSINFO fsInfo;
          rc=DosQueryFSInfo(i+1, FSIL_VOLSER, &fsInfo,sizeof(fsInfo));
          printf("%s %s %d %s\n",chrDrive, pfsqBuf2->szName+pfsqBuf2->cbName+1, i+1, fsInfo.vol.szVolLabel); 
        }
      }
      else
        printf("%s %s\n",chrDrive, "---"); 
    }
  }
  DosError(FERR_ENABLEHARDERR);
    
  printf("\n\nDone");
  
  return 0;
}
/* This Proc handles the ISO image mounting */
MRESULT EXPENTRY unmountIsoDialogProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
  char text[CCHMAXPATH];
  char title[CCHMAXPATH];

  ULONG rc;
  SWCNTRL swctl;
  PID pid;

  switch (msg)
    {      
    case WM_INITDLG:
      {
        BOOL bDone=FALSE;
        int i;

        writeLog("Initializing dialog...\n");  
        
        /* Add switch entry */
        memset(&swctl,0,sizeof(swctl));
        WinQueryWindowProcess(hwnd,&pid,NULL);
        swctl.hwnd=hwnd;
        swctl.uchVisibility=SWL_VISIBLE;
        swctl.idProcess=pid;
        swctl.bProgType=PROG_DEFAULT;
        swctl.fbJump=SWL_JUMPABLE;
        WinAddSwitchEntry(&swctl);
        
        /*sprintf(text,"%d",params[4]);*/ 
        // sprintf(text,"params[1]: %s ",params[1]);
        /* WinMessageBox( HWND_DESKTOP, HWND_DESKTOP, pvSharedMem,
           params[4],
           0UL, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE );
           WinPostMsg(hwnd,WM_CLOSE,0,0);
           return (MRESULT) TRUE;
           */
        
        /* Get free drive letters */
        if((rc=DosQueryCurrentDisk(&ulDriveNum, &ulDriveMap))!=NO_ERROR)
          WinPostMsg(hwnd,WM_CLOSE,0,0);

        DosError(FERR_DISABLEHARDERR);

        for(i=2;i<26;i++) {
          if(( (ulDriveMap << (31-i)) >>31)) {
            char chrDrive[3]="A:";
            BYTE fsqBuf2[sizeof(FSQBUFFER2)+3*CCHMAXPATH]={0};
            PFSQBUFFER2 pfsqBuf2=(PFSQBUFFER2) &fsqBuf2;
            ULONG ulLength;

            /* Get FS */
            chrDrive[0]='A'+i;
            ulLength=sizeof(fsqBuf2);
            if(DosQueryFSAttach(chrDrive,0L,FSAIL_QUERYNAME, (PFSQBUFFER2)&fsqBuf2, &ulLength)==NO_ERROR) {
              if(!strcmp(pfsqBuf2->szName+pfsqBuf2->cbName+1,"ISOFS")) {
                FSINFO fsInfo;

                if(DosQueryFSInfo(i+1, FSIL_VOLSER, &fsInfo,sizeof(fsInfo))==NO_ERROR)
                  sprintf(text, "%s      (%s)",chrDrive,  fsInfo.vol.szVolLabel); 
                else
                  sprintf(text, "%s      (unknown)",chrDrive); 
                WinSendMsg(WinWindowFromID(hwnd, IDLB_UNMOUNTLETTER),LM_INSERTITEM,MPFROMSHORT(LIT_END),MPFROMP(text));
              }
            }
            else
              printf("%s %s\n",chrDrive, "---"); 
          }
        }
        DosError(FERR_ENABLEHARDERR);

        /* Set dialog font to WarpSans for Warp 4 and above */
        if(cwQueryOSRelease()>=40) {
          WinSetPresParam(hwnd,
                          PP_FONTNAMESIZE,(ULONG)sizeof(DEFAULT_DIALOG_FONT),
                          DEFAULT_DIALOG_FONT );
        }
        
        if(!bHaveWindowPos)
          WinSetWindowPos(hwnd,HWND_TOP,0,0,0,0,SWP_ZORDER|SWP_ACTIVATE);
        else
          WinSetWindowPos(hwnd,HWND_TOP,swpWindow.x, swpWindow.y, 0, 0, SWP_MOVE|SWP_ZORDER|SWP_ACTIVATE|SWP_SHOW);
        
        return (MRESULT) TRUE;
      }
    case WM_CLOSE:
      WinQueryWindowPos(hwnd,&swpWindow);
      WinDismissDlg(hwnd,0);
      return FALSE;
    case WM_HELP:
      sendCommand("DISPLAYHELPPANEL=5100");      
      break;
    case WM_COMMAND:
      switch(SHORT1FROMMP(mp1))
        {
        case IDPB_UNMOUNT:
          {
            /* User pressed the Unount button */
            AEFS_DETACH detachparms={0};
            char pszDrive[3]={0};
            HOBJECT hObject;
            SHORT sSelected;
            memset(&detachparms, 0, sizeof(detachparms));

            /* Get the drive letter */
            sSelected=SHORT1FROMMR(WinSendMsg(WinWindowFromID(hwnd, IDLB_UNMOUNTLETTER),LM_QUERYSELECTION,
                                             MPFROMSHORT(LIT_FIRST),MPFROMLONG(0L)));
            if(sSelected==LIT_NONE)
              break;

            WinSendMsg(WinWindowFromID(hwnd, IDLB_UNMOUNTLETTER),LM_QUERYITEMTEXT,
                       MPFROM2SHORT(sSelected,2),MPFROMP(pszDrive));

            /* Send the attachment request to the FSD. */
            rc = DosFSAttach(
                             //                             (PSZ) "",
                             (PSZ) pszDrive,
                             (PSZ) AEFS_IFS_NAME,
                             &detachparms,
                             sizeof(detachparms),
                             FS_DETACH);
            if (rc) {
              DosBeep(100,400);             
                            
              sprintf(text, "Error while unmounting rc=%d. Make sure there're no open files on the drive.\n", rc);
              WinMessageBox( HWND_DESKTOP, HWND_DESKTOP, text,
                             "ISO image unmount error",
                             0UL, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE );
            }else {
              WinSendMsg(WinWindowFromID(hwnd, IDLB_UNMOUNTLETTER),LM_DELETEITEM,
                         MPFROMSHORT(sSelected),MPFROMLONG(0L));
              sSelected=SHORT1FROMMR(WinSendMsg(WinWindowFromID(hwnd, IDLB_UNMOUNTLETTER),LM_QUERYITEMCOUNT,
                                                MPFROMLONG(0L),MPFROMLONG(0L)));
              if(sSelected==0)
                WinEnableWindow(WinWindowFromID(hwnd,IDPB_UNMOUNT), FALSE);
            }

            break;
          }
        case IDPB_UNMOUNTCLOSE:
          WinPostMsg(hwnd,WM_CLOSE,0,0);
          break;
        default:
          break;
        }
      return (MRESULT) FALSE;
    default:
      break;
    }
  return WinDefDlgProc(hwnd, msg, mp1, mp2);    
}
예제 #29
0
파일: os2_rand.c 프로젝트: dryeo/Pale-Moon
void RNG_SystemInfoForRNG(void)
{
   unsigned long *plong = 0;
   PTIB ptib;
   PPIB ppib;
   APIRET rc = NO_ERROR;
   DATETIME dt;
   COUNTRYCODE cc = {0};
   COUNTRYINFO ci = {0};
   unsigned long actual = 0;
   char path[_MAX_PATH]="";
   char fullpath[_MAX_PATH]="";
   unsigned long pathlength = sizeof(path);
   FSALLOCATE fsallocate;
   FILESTATUS3 fstatus;
   unsigned long defaultdrive = 0;
   unsigned long logicaldrives = 0;
   unsigned long sysInfo[QSV_MAX] = {0};
   char buffer[20];
   int nBytes = 0;

   nBytes = RNG_GetNoise(buffer, sizeof(buffer));
   RNG_RandomUpdate(buffer, nBytes);
   
   /* allocate memory and use address and memory */
   plong = (unsigned long *)malloc(sizeof(*plong));
   RNG_RandomUpdate(&plong, sizeof(plong));
   RNG_RandomUpdate(plong, sizeof(*plong));
   free(plong);

   /* process info */
   rc = DosGetInfoBlocks(&ptib, &ppib);
   if (rc == NO_ERROR)
   {
      RNG_RandomUpdate(ptib, sizeof(*ptib));
      RNG_RandomUpdate(ppib, sizeof(*ppib));
   }

   /* time */
   rc = DosGetDateTime(&dt);
   if (rc == NO_ERROR)
   {
      RNG_RandomUpdate(&dt, sizeof(dt));
   }

   /* country */
   rc = DosQueryCtryInfo(sizeof(ci), &cc, &ci, &actual);
   if (rc == NO_ERROR)
   {
      RNG_RandomUpdate(&cc, sizeof(cc));
      RNG_RandomUpdate(&ci, sizeof(ci));
      RNG_RandomUpdate(&actual, sizeof(actual));
   }

   /* current directory */
   rc = DosQueryCurrentDir(0, path, &pathlength);
   strcat(fullpath, "\\");
   strcat(fullpath, path);
   if (rc == NO_ERROR)
   {
      RNG_RandomUpdate(fullpath, strlen(fullpath));
      // path info
      rc = DosQueryPathInfo(fullpath, FIL_STANDARD, &fstatus, sizeof(fstatus));
      if (rc == NO_ERROR)
      {
         RNG_RandomUpdate(&fstatus, sizeof(fstatus));
      }
   }

   /* file system info */
   rc = DosQueryFSInfo(0, FSIL_ALLOC, &fsallocate, sizeof(fsallocate));
   if (rc == NO_ERROR)
   {
      RNG_RandomUpdate(&fsallocate, sizeof(fsallocate));
   }

   /* drive info */
   rc = DosQueryCurrentDisk(&defaultdrive, &logicaldrives);
   if (rc == NO_ERROR)
   {
      RNG_RandomUpdate(&defaultdrive, sizeof(defaultdrive));
      RNG_RandomUpdate(&logicaldrives, sizeof(logicaldrives));
   }

   /* system info */
   rc = DosQuerySysInfo(1L, QSV_MAX, (PVOID)&sysInfo, sizeof(ULONG)*QSV_MAX);
   if (rc == NO_ERROR)
   {
      RNG_RandomUpdate(&sysInfo, sizeof(sysInfo));
   }

   // now let's do some files
   ReadSystemFiles();

   /* more noise */
   nBytes = RNG_GetNoise(buffer, sizeof(buffer));
   RNG_RandomUpdate(buffer, nBytes);
}
void 
my_statfs (struct my_statfs *myfs_stats, char *path)
{
    PFSALLOCATE pBuf;
    PFSINFO     pFsInfo;
    ULONG       lghBuf;

    ULONG       diskNum = 0;
    ULONG       logical = 0;

    UCHAR       szDeviceName[3] = "A:";
    PBYTE       pszFSDName      = NULL;  /* pointer to FS name            */
    APIRET      rc              = NO_ERROR; /* Return code                */
    BYTE        fsqBuffer[sizeof(FSQBUFFER2) + (3 * CCHMAXPATH)] = {0};
    ULONG       cbBuffer   = sizeof(fsqBuffer);        /* Buffer length) */
    PFSQBUFFER2 pfsqBuffer = (PFSQBUFFER2) fsqBuffer;

    int i, len = 0;

    /* ------------------------------------------------------------------ */

    lghBuf = sizeof(FSALLOCATE);
    pBuf = (PFSALLOCATE) malloc(lghBuf);

    /* Get the free number of Bytes */
    rc = DosQueryFSInfo(0L, FSIL_ALLOC, (PVOID) pBuf, lghBuf);
    /* KBytes available */
    myfs_stats->avail = pBuf->cSectorUnit * pBuf->cUnitAvail * pBuf->cbSector / 1024;
    /* KBytes total */
    myfs_stats->total = pBuf->cSectorUnit * pBuf->cUnit * pBuf->cbSector / 1024; 
    myfs_stats->nfree = pBuf->cUnitAvail;
    myfs_stats->nodes = pBuf->cbSector;

    lghBuf  = sizeof(FSINFO);
    pFsInfo = (PFSINFO) malloc(lghBuf);
    rc      = DosQueryFSInfo(0L, 
                             FSIL_VOLSER, 
                             (PVOID) pFsInfo, 
                             lghBuf);
    /* Get name */
    myfs_stats->device = strdup(pFsInfo->vol.szVolLabel);    /* Label of the Disk */

    /* Get the current disk for DosQueryFSAttach */
    rc = DosQueryCurrentDisk(&diskNum, &logical);

    szDeviceName[0] = (UCHAR) (diskNum + (ULONG) 'A' - 1);
    /* Now get the type of the disk */
    rc = DosQueryFSAttach(szDeviceName, 
                          0L, 
                          FSAIL_QUERYNAME, 
                          pfsqBuffer, 
                          &cbBuffer);

    pszFSDName = pfsqBuffer->szName + pfsqBuffer->cbName + 1;
    myfs_stats->mpoint = strdup(pszFSDName);    /* FAT, HPFS ... */

    myfs_stats->type = pBuf->idFileSystem;
    /* What is about 3 ?*/
    if (myfs_stats->type == 0) {
       myfs_stats->typename = (char *) malloc(11);
       strcpy(myfs_stats->typename, "Local Disk");
    } else {