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 >
Wrap
Text File
|
1994-09-15
|
5KB
|
141 lines
// DosIntr.lib - Dos interrupt calls. These functions are provide
// ver.3 interfaces to some of the low-level DOS calls.
// This library can be used with CEnvi for DOS or
// CEnvi for Windows.
//
//**** CreateDirectory(): Create a directory
// SYNTAX: bool CreateDirectory(string DirectorySpec)
// WHERE: DirectorySpec is the name of the directory to create
// RETURN: Return False if error (cannot create or already exists)
// EXAMPLE: CreateDirectory("C:\\TESTDIR");
// NOTE: Use Directory() function to test if directory exists
//
//**** DeleteDirectory(): Delete a directory
// SYNTAX: bool DeleteDirectory(string DirectorySpec)
// WHERE: DirectorySpec is the name of the directory to delete
// RETURN: Return False if error (cannot delete or no directory exists)
// EXAMPLE: DeleteDirectory("C:\\TESTDIR");
//
//**** RenameFile(): Rename file or move within same drive
// SYNTAX: bool RenameFile(string OldName,string NewName)
// WHERE: OldName is old file name, including path
// NewName is the new file name, including path
// RETURN: Return False if error
// EXAMPLE: RenameFile("C:\\GOOBER\\MYFILE.TXT","C:\\YOURFILE.TXT");
// NOTE: Cannot move a file between drives; OldName and NewName are
// relative to current directory
//
//**** SetCurrentDirectory(): Change drive to different directory
// SYNTAX: bool SetCurrentDirectory(string DirectorySpec)
// WHERE: DirectorySpec is the name of an existing directory
// RETURN: Return False if error
// EXAMPLE: SetCurrentDirectory("C:\\TESTDIR");
// NOTE: If DirectorySpec includes drive letter, then will not change
// current drive to that drive; see SetCurrentDrive(). For
// getting current directory use FullPath(".")
//
//**** SetCurrentDrive(): Change to a different drive letter
// SYNTAX: bool SetCurrentDirectory(char DriveLetter)
// WHERE: DriveLetter is character drive letter to change to
// RETURN: Return False if unable to change to drive letter
// EXAMPLE: SetCurrentDrive('C');
// NOTE: Current drive letter is FullPath(".")[0]
//
//**** SetFileAttributes(): Set File Attributes
// SYNTAX: bool SetFileAttributes(string FileName,int Attributes)
// WHERE: FileName: name of existing file
// Atrribute: OR of flags as defined in the Directory() function
// RETURN: Return false for failure
// NOTE: Use Directory() to read file attributes; this call does not
// access volumes or subdirectories; Normal attribute is 0
//
//**** SetFileDateAndTime(): set time and date of last write
// SYNTAX: bool SetFileDateAndTime(string FileName,int Time)
// WHERE: FileName: name of existing file
// Time: as returned by the time() call or by Directory()
// RETURN: Return false for failure
//
CreateDirectory(pDirSpec)
{
lReg.ah = 0x39;
lReg.ds = segment(pDirSpec);
lREg.dx = offset(pDirSpec);
return interrupt(0x21,lReg);
}
DeleteDirectory(pDirSpec)
{
lReg.ah = 0x3A;
lReg.ds = segment(pDirSpec);
lREg.dx = offset(pDirSpec);
return interrupt(0x21,lReg);
}
SetCurrentDirectory(pDirSpec)
{
lReg.ah = 0x3B;
lReg.ds = segment(pDirSpec);
lReg.dx = offset(pDirSpec);
return interrupt(0x21,lReg);
}
SetCurrentDrive(pDriveLetter)
{
lReg.ah = 0x0E;
lReg.dl = toupper(pDriveLetter) - 'A';
interrupt(0x21,lReg);
return ( (lFullP = FullPath(".")) && lFullP[0] == toupper(pDriveLetter) );
}
SetFileAttributes(pFileName,pAttributes)
{
lReg.ah = 0x43;
lReg.al = 1;
lReg.cx = pAttributes;
lReg.ds = segment(pFileName);
lReg.dx = offset(pFileName);
return interrupt(0x21,lReg);
}
SetFileDateAndTime(pFileName,pTime)
{
lSuccess = False;
// Open file to get a handle
lReg.ah = 0x3D;
lReg.al = 0x42;
lReg.ds = segment(pFileName);
lReg.dx = offset(pFileName);
if ( interrupt(0x21,lReg,lRegout) ) {
lHandle = lRegout.ax;
// write date to file
undefine(lReg);
lReg.ah = 0x57;
lReg.al = 1;
lReg.bx = lHandle;
lTm = localtime(pTime);
lReg.cx = (lTm.tm_sec / 2)
| (lTm.tm_min << 5)
| (lTm.tm_hour << 11);
lReg.dx = lTm.tm_mday
| ((lTm.tm_mon+1) << 5)
| ((lTm.tm_year-80) << 10);
lSuccess = interrupt(0x21,lReg);
// close file
undefine(lReg);
lReg.ah = 0x3E;
lReg.bx = lHandle;
interrupt(0x21,lReg);
}
return lSuccess;
}
RenameFile(pOldName,pNewName)
{
lReg.ah = 0x56;
lReg.ds = segment(pOldName); lReg.dx = offset(pOldName);
lReg.es = segment(pNewName); lReg.di = offset(pNewName);
return interrupt(0x21,lReg);
}