home *** CD-ROM | disk | FTP | other *** search
/ The Pier Shareware 6 / The_Pier_Shareware_Number_6_(The_Pier_Exchange)_(1995).iso / 035 / cenvi29.zip / DOSINTR.LIB < prev    next >
Text File  |  1994-09-15  |  5KB  |  141 lines

  1. // DosIntr.lib - Dos interrupt calls.  These functions are provide
  2. // ver.3         interfaces to some of the low-level DOS calls.
  3. //               This library can be used with CEnvi for DOS or
  4. //               CEnvi for Windows.
  5. //
  6. //**** CreateDirectory(): Create a directory
  7. // SYNTAX: bool CreateDirectory(string DirectorySpec)
  8. // WHERE: DirectorySpec is the name of the directory to create
  9. // RETURN: Return False if error (cannot create or already exists)
  10. // EXAMPLE: CreateDirectory("C:\\TESTDIR");
  11. // NOTE: Use Directory() function to test if directory exists
  12. //
  13. //**** DeleteDirectory(): Delete a directory
  14. // SYNTAX: bool DeleteDirectory(string DirectorySpec)
  15. // WHERE: DirectorySpec is the name of the directory to delete
  16. // RETURN: Return False if error (cannot delete or no directory exists)
  17. // EXAMPLE: DeleteDirectory("C:\\TESTDIR");
  18. //
  19. //**** RenameFile(): Rename file or move within same drive
  20. // SYNTAX: bool RenameFile(string OldName,string NewName)
  21. // WHERE: OldName is old file name, including path
  22. //        NewName is the new file name, including path
  23. // RETURN: Return False if error
  24. // EXAMPLE: RenameFile("C:\\GOOBER\\MYFILE.TXT","C:\\YOURFILE.TXT");
  25. // NOTE: Cannot move a file between drives; OldName and NewName are
  26. //       relative to current directory
  27. //
  28. //**** SetCurrentDirectory(): Change drive to different directory
  29. // SYNTAX: bool SetCurrentDirectory(string DirectorySpec)
  30. // WHERE: DirectorySpec is the name of an existing directory
  31. // RETURN: Return False if error
  32. // EXAMPLE: SetCurrentDirectory("C:\\TESTDIR");
  33. // NOTE: If DirectorySpec includes drive letter, then will not change
  34. //       current drive to that drive; see SetCurrentDrive().  For
  35. //       getting current directory use FullPath(".")
  36. //
  37. //**** SetCurrentDrive(): Change to a different drive letter
  38. // SYNTAX: bool SetCurrentDirectory(char DriveLetter)
  39. // WHERE: DriveLetter is character drive letter to change to
  40. // RETURN: Return False if unable to change to drive letter
  41. // EXAMPLE: SetCurrentDrive('C');
  42. // NOTE: Current drive letter is FullPath(".")[0]
  43. //
  44. //**** SetFileAttributes(): Set File Attributes
  45. // SYNTAX: bool SetFileAttributes(string FileName,int Attributes)
  46. // WHERE: FileName: name of existing file
  47. //        Atrribute: OR of flags as defined in the Directory() function
  48. // RETURN: Return false for failure
  49. // NOTE: Use Directory() to read file attributes; this call does not
  50. //       access volumes or subdirectories; Normal attribute is 0
  51. //
  52. //**** SetFileDateAndTime(): set time and date of last write
  53. // SYNTAX: bool SetFileDateAndTime(string FileName,int Time)
  54. // WHERE: FileName: name of existing file
  55. //        Time: as returned by the time() call or by Directory()
  56. // RETURN: Return false for failure
  57. //
  58.  
  59. CreateDirectory(pDirSpec)
  60. {
  61.    lReg.ah = 0x39;
  62.    lReg.ds = segment(pDirSpec);
  63.    lREg.dx = offset(pDirSpec);
  64.    return interrupt(0x21,lReg);
  65. }
  66.  
  67. DeleteDirectory(pDirSpec)
  68. {
  69.    lReg.ah = 0x3A;
  70.    lReg.ds = segment(pDirSpec);
  71.    lREg.dx = offset(pDirSpec);
  72.    return interrupt(0x21,lReg);
  73. }
  74.  
  75. SetCurrentDirectory(pDirSpec)
  76. {
  77.    lReg.ah = 0x3B;
  78.    lReg.ds = segment(pDirSpec);
  79.    lReg.dx = offset(pDirSpec);
  80.    return interrupt(0x21,lReg);
  81. }
  82.  
  83. SetCurrentDrive(pDriveLetter)
  84. {
  85.    lReg.ah = 0x0E;
  86.    lReg.dl = toupper(pDriveLetter) - 'A';
  87.    interrupt(0x21,lReg);
  88.    return ( (lFullP = FullPath(".")) && lFullP[0] == toupper(pDriveLetter) );
  89. }
  90.  
  91. SetFileAttributes(pFileName,pAttributes)
  92. {
  93.    lReg.ah = 0x43;
  94.    lReg.al = 1;
  95.    lReg.cx = pAttributes;
  96.    lReg.ds = segment(pFileName);
  97.    lReg.dx = offset(pFileName);
  98.    return interrupt(0x21,lReg);
  99. }
  100.  
  101. SetFileDateAndTime(pFileName,pTime)
  102. {
  103.    lSuccess = False;
  104.    // Open file to get a handle
  105.    lReg.ah = 0x3D;
  106.    lReg.al = 0x42;
  107.    lReg.ds = segment(pFileName);
  108.    lReg.dx = offset(pFileName);
  109.    if ( interrupt(0x21,lReg,lRegout) ) {
  110.       lHandle = lRegout.ax;
  111.       // write date to file
  112.       undefine(lReg);
  113.       lReg.ah = 0x57;
  114.       lReg.al = 1;
  115.       lReg.bx = lHandle;
  116.       lTm = localtime(pTime);
  117.       lReg.cx = (lTm.tm_sec / 2)
  118.               | (lTm.tm_min << 5)
  119.               | (lTm.tm_hour << 11);
  120.       lReg.dx = lTm.tm_mday
  121.               | ((lTm.tm_mon+1) << 5)
  122.               | ((lTm.tm_year-80) << 10);
  123.       lSuccess = interrupt(0x21,lReg);
  124.       // close file
  125.       undefine(lReg);
  126.       lReg.ah = 0x3E;
  127.       lReg.bx = lHandle;
  128.       interrupt(0x21,lReg);
  129.    }
  130.    return lSuccess;
  131. }
  132.  
  133. RenameFile(pOldName,pNewName)
  134. {
  135.    lReg.ah = 0x56;
  136.    lReg.ds = segment(pOldName); lReg.dx = offset(pOldName);
  137.    lReg.es = segment(pNewName); lReg.di = offset(pNewName);
  138.    return interrupt(0x21,lReg);
  139. }
  140.  
  141.