本文整理汇总了C++中DOS_MakeName函数的典型用法代码示例。如果您正苦于以下问题:C++ DOS_MakeName函数的具体用法?C++ DOS_MakeName怎么用?C++ DOS_MakeName使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了DOS_MakeName函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DOS_Rename
bool DOS_Rename(char const * const oldname,char const * const newname) {
Bit8u driveold;char fullold[DOS_PATHLENGTH];
Bit8u drivenew;char fullnew[DOS_PATHLENGTH];
if (!DOS_MakeName(oldname,fullold,&driveold)) return false;
if (!DOS_MakeName(newname,fullnew,&drivenew)) return false;
/* No tricks with devices */
if ( (DOS_FindDevice(oldname) != DOS_DEVICES) ||
(DOS_FindDevice(newname) != DOS_DEVICES) ) {
DOS_SetError(DOSERR_FILE_NOT_FOUND);
return false;
}
/* Must be on the same drive */
if(driveold != drivenew) {
DOS_SetError(DOSERR_NOT_SAME_DEVICE);
return false;
}
/*Test if target exists => no access */
Bit16u attr;
if(Drives[drivenew]->GetFileAttr(fullnew,&attr)) {
DOS_SetError(DOSERR_ACCESS_DENIED);
return false;
}
/* Source must exist, check for path ? */
if (!Drives[driveold]->GetFileAttr( fullold, &attr ) ) {
DOS_SetError(DOSERR_FILE_NOT_FOUND);
return false;
}
if (Drives[drivenew]->Rename(fullold,fullnew)) return true;
/* If it still fails. which error should we give ? PATH NOT FOUND or EACCESS */
LOG(LOG_FILES,LOG_NORMAL)("Rename fails for %s to %s, no proper errorcode returned.",oldname,newname);
DOS_SetError(DOSERR_FILE_NOT_FOUND);
return false;
}
示例2: DOS_FCBOpen
bool DOS_FCBOpen(Bit16u seg,Bit16u offset) {
DOS_FCB fcb(seg,offset);
char shortname[DOS_FCBNAME];Bit16u handle;
fcb.GetName(shortname);
/* First check if the name is correct */
Bit8u drive;
char fullname[DOS_PATHLENGTH];
if (!DOS_MakeName(shortname,fullname,&drive)) return false;
/* Check, if file is already opened */
for (Bit8u i=0;i<DOS_FILES;i++) {
DOS_PSP psp(dos.psp());
if (Files[i] && Files[i]->IsOpen() && Files[i]->IsName(fullname)) {
handle = psp.FindEntryByHandle(i);
if (handle==0xFF) {
// This shouldnt happen
LOG(LOG_FILES,LOG_ERROR)("DOS: File %s is opened but has no psp entry.",shortname);
return false;
}
fcb.FileOpen((Bit8u)handle);
return true;
}
}
if (!DOS_OpenFile(shortname,OPEN_READWRITE,&handle)) return false;
fcb.FileOpen((Bit8u)handle);
return true;
}
示例3: DOS_FCBRenameFile
bool DOS_FCBRenameFile(Bit16u seg, Bit16u offset) {
DOS_FCB fcbold(seg,offset);
DOS_FCB fcbnew(seg,offset+16);
if(!fcbold.Valid()) return false;
char oldname[DOS_FCBNAME];
char newname[DOS_FCBNAME];
fcbold.GetName(oldname);
fcbnew.GetName(newname);
/* Check, if sourcefile is still open. This was possible in DOS, but modern oses don't like this */
Bit8u drive;
char fullname[DOS_PATHLENGTH];
if (!DOS_MakeName(oldname,fullname,&drive)) return false;
DOS_PSP psp(dos.psp());
for (Bit8u i=0; i<DOS_FILES; i++) {
if (Files[i] && Files[i]->IsOpen() && Files[i]->IsName(fullname)) {
Bit16u handle = psp.FindEntryByHandle(i);
//(more than once maybe)
if (handle == 0xFF) {
DOS_CloseFile(i,true);
} else {
DOS_CloseFile(handle);
}
}
}
/* Rename the file */
return DOS_Rename(oldname,newname);
}
示例4: DOS_RemoveDir
bool DOS_RemoveDir(char const * const dir) {
/* We need to do the test before the removal as can not rely on
* the host to forbid removal of the current directory.
* We never change directory. Everything happens in the drives.
*/
Bit8u drive;
char fulldir[DOS_PATHLENGTH];
if (!DOS_MakeName(dir,fulldir,&drive)) return false;
/* Check if exists */
if(!Drives[drive]->TestDir(fulldir)) {
DOS_SetError(DOSERR_PATH_NOT_FOUND);
return false;
}
/* See if it's current directory */
char currdir[DOS_PATHLENGTH]= { 0 };
DOS_GetCurrentDir(drive + 1 ,currdir);
if(strcmp(currdir,fulldir) == 0) {
DOS_SetError(DOSERR_REMOVE_CURRENT_DIRECTORY);
return false;
}
if(Drives[drive]->RemoveDir(fulldir)) return true;
/* Failed. We know it exists and it's not the current dir */
/* Assume non empty */
DOS_SetError(DOSERR_ACCESS_DENIED);
return false;
}
示例5: DOS_MakeDir
bool DOS_MakeDir(char const* const dir)
{
Bit8u drive;
const char *testdir = dir;
if (*testdir && testdir[1] == ':')
{
drive = (*testdir | 0x20)-'a';
if (drive >= DOS_DRIVES || !Drives[drive])
{
DOS_SetError(DOSERR_INVALID_DRIVE);
return false;
}
testdir += 2;
}
size_t len = strlen(testdir);
char fulldir[DOS_PATHLENGTH];
if (!len || !DOS_MakeName(dir, fulldir, &drive) || (*fulldir && testdir[len-1] == '\\'))
{
DOS_SetError(DOSERR_PATH_NOT_FOUND);
return false;
}
if (Drives[drive]->MakeDir(fulldir))
return true;
if (Drives[drive]->TestDir(fulldir)) // Determine reason for failing
DOS_SetError(DOSERR_ACCESS_DENIED);
else
DOS_SetError(DOSERR_PATH_NOT_FOUND);
return false;
}
示例6: DOS_ChangeDir
bool DOS_ChangeDir(char const* const dir)
{
Bit8u drive;
const char *testdir = dir;
if (*testdir && testdir[1] == ':')
{
drive = (*dir | 0x20)-'a';
if (drive >= DOS_DRIVES || !Drives[drive])
{
DOS_SetError(DOSERR_INVALID_DRIVE);
return false;
}
testdir += 2;
}
size_t len = strlen(testdir);
char fulldir[DOS_PATHLENGTH];
if (!len || !DOS_MakeName(dir, fulldir, &drive) || (*fulldir && testdir[len-1] == '\\'))
{ }
else if (Drives[drive]->TestDir(fulldir))
{
for (int i = 0; fulldir[i]; i++) // Names in MS-DOS are allways uppercase
fulldir[i] = toupper(fulldir[i]);
strcpy(Drives[drive]->curdir, fulldir);
return true;
}
DOS_SetError(DOSERR_PATH_NOT_FOUND);
return false;
}
示例7: DOS_FindDevice
Bit8u DOS_FindDevice(char const * name) {
/* should only check for the names before the dot and spacepadded */
char fullname[DOS_PATHLENGTH];Bit8u drive;
// if(!name || !(*name)) return DOS_DEVICES; //important, but makename does it
if (!DOS_MakeName(name,fullname,&drive)) return DOS_DEVICES;
char* name_part = strrchr(fullname,'\\');
if(name_part) {
*name_part++ = 0;
//Check validity of leading directory.
if(!Drives[drive]->TestDir(fullname)) return DOS_DEVICES;
} else name_part = fullname;
char* dot = strrchr(name_part,'.');
if(dot) *dot = 0; //no ext checking
static char com[5] = { 'C','O','M','1',0 };
static char lpt[5] = { 'L','P','T','1',0 };
// AUX is alias for COM1 and PRN for LPT1
// A bit of a hack. (but less then before).
// no need for casecmp as makename returns uppercase
if (strcmp(name_part, "AUX") == 0) name_part = com;
if (strcmp(name_part, "PRN") == 0) name_part = lpt;
/* loop through devices */
for(Bit8u index = 0;index < DOS_DEVICES;index++) {
if (Devices[index]) {
if (WildFileCmp(name_part,Devices[index]->name)) return index;
}
}
return DOS_DEVICES;
}
示例8: DOS_FileExists
bool DOS_FileExists(char const* const name)
{
char fullname[DOS_PATHLENGTH];
Bit8u drive;
if (!DOS_MakeName(name, fullname, &drive))
return false;
return Drives[drive]->FileExists(fullname);
}
示例9: DOS_CreateOpenFile
void* DOS_CreateOpenFile(char const* const name)
{
char fullname[DOS_PATHLENGTH];
Bit8u drive;
if (!DOS_MakeName(name, fullname, &drive))
return NULL;
return Drives[drive]->CreateOpenFile(fullname);
}
示例10: DOS_GetCompressedFileSize
Bit32u DOS_GetCompressedFileSize(char const* const name)
{
char fullname[DOS_PATHLENGTH];
Bit8u drive;
if (!DOS_MakeName(name, fullname, &drive))
return false;
return Drives[drive]->GetCompressedSize(fullname);
}
示例11: DOS_GetSFNPath
bool DOS_GetSFNPath(char const * const path,char * SFNPath,bool LFN) {
char dir_current[DOS_PATHLENGTH + 1], pdir[LFN_NAMELENGTH], *p;
Bit8u drive;char fulldir[DOS_PATHLENGTH],LFNPath[CROSS_LEN];
char name[DOS_NAMELENGTH_ASCII], lname[LFN_NAMELENGTH];
int w=0;
DOS_DTA dta(dos.dta());
Bit32u size;Bit16u date;Bit16u time;Bit8u attr;
if (!DOS_MakeName(path,fulldir,&drive)) return false;
sprintf(SFNPath,"%c:\\",drive+'A');
strcpy(LFNPath,SFNPath);
strcpy(dir_current,Drives[drive]->curdir);
Drives[drive]->curdir,"";
p = fulldir;
if (*p==0) return true;
for (char *s = strchr(p,'\\'); s != NULL; s = strchr(p,'\\')) {
*s = 0;
if (SFNPath[strlen(SFNPath)-1]=='\\')
sprintf(pdir,"\"%s%s\"",SFNPath,p);
else
sprintf(pdir,"\"%s\\%s\"",SFNPath,p);
if (!strrchr(p,'*') && !strrchr(p,'?')) {
*s = '\\';
p = s + 1;
if (DOS_FindFirst(pdir,0xffff & DOS_ATTR_DIRECTORY & ~DOS_ATTR_VOLUME,false)) {
dta.GetResult(name,lname,size,date,time,attr);
strcat(SFNPath,name);
strcat(LFNPath,lname);
Drives[drive]->curdir,SFNPath+3;
strcat(SFNPath,"\\");
strcat(LFNPath,"\\");
}
else {
return false;}
} else {
strcat(SFNPath,p);
strcat(LFNPath,p);
strcat(SFNPath,"\\");
strcat(LFNPath,"\\");
*s = '\\';
p = s + 1;
break;
}
}
if (p != 0) {
sprintf(pdir,"\"%s%s\"",SFNPath,p);
if (!strrchr(p,'*')&&!strrchr(p,'?')&&DOS_FindFirst(pdir,0xffff & ~DOS_ATTR_VOLUME,false)) {
dta.GetResult(name,lname,size,date,time,attr);
strcat(SFNPath,name);
strcat(LFNPath,lname);
} else {
strcat(SFNPath,p);
strcat(LFNPath,p);
}
}
Drives[drive]->curdir,dir_current;
if (LFN) strcpy(SFNPath,LFNPath);
return true;
}
示例12: DOS_Canonicalize
bool DOS_Canonicalize(char const* const name, char* const big)
{
// TODO Add Better support for devices and shit but will it be needed i doubt it :)
if (!DOS_MakeName(name, &big[3], (Bit8u *)big))
return false;
big[0] += 'A';
big[1] = ':';
big[2] = '\\';
return true;
}
示例13: DOS_GetFileAttr
bool DOS_GetFileAttr(char const * const name,Bit16u * attr) {
char fullname[DOS_PATHLENGTH];Bit8u drive;
if (!DOS_MakeName(name,fullname,&drive)) return false;
if (Drives[drive]->GetFileAttr(fullname,attr)) {
return true;
} else {
DOS_SetError(DOSERR_FILE_NOT_FOUND);
return false;
}
}
示例14: DOS_UnlinkFile
bool DOS_UnlinkFile(char const * const name) {
char fullname[DOS_PATHLENGTH];Bit8u drive;
if (!DOS_MakeName(name,fullname,&drive)) return false;
if(Drives[drive]->FileUnlink(fullname)){
return true;
} else {
DOS_SetError(DOSERR_FILE_NOT_FOUND);
return false;
}
}
示例15: DOS_GetFileAttrEx
bool DOS_GetFileAttrEx(char const* const name, struct stat *status, Bit8u hdrive)
{
char fullname[DOS_PATHLENGTH];
Bit8u drive;
bool usehdrive=hdrive>=0&&hdrive<DOS_FILES;
if (usehdrive)
strcpy(fullname,name);
else if (!DOS_MakeName(name, fullname, &drive))
return false;
return Drives[usehdrive?hdrive:drive]->GetFileAttrEx(fullname, status);
}