本文整理汇总了C++中IsPathDiv函数的典型用法代码示例。如果您正苦于以下问题:C++ IsPathDiv函数的具体用法?C++ IsPathDiv怎么用?C++ IsPathDiv使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了IsPathDiv函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ConvertPath
wchar* ConvertPath(const wchar *SrcPath,wchar *DestPath)
{
const wchar *DestPtr=SrcPath;
for (const wchar *s=DestPtr;*s!=0;s++)
if (IsPathDiv(s[0]) && s[1]=='.' && s[2]=='.' && IsPathDiv(s[3]))
DestPtr=s+4;
while (*DestPtr)
{
const wchar *s=DestPtr;
if (s[0] && IsDriveDiv(s[1]))
s+=2;
if (s[0]=='\\' && s[1]=='\\')
{
const wchar *Slash=strchrw(s+2,'\\');
if (Slash!=NULL && (Slash=strchrw(Slash+1,'\\'))!=NULL)
s=Slash+1;
}
for (const wchar *t=s;*t!=0;t++)
if (IsPathDiv(*t))
s=t+1;
else
if (*t!='.')
break;
if (s==DestPtr)
break;
DestPtr=s;
}
if (DestPath!=NULL)
{
wchar TmpStr[NM];
strncpyw(TmpStr,DestPtr,sizeof(TmpStr)/sizeof(TmpStr[0])-1);
strcpyw(DestPath,TmpStr);
}
return((wchar *)DestPtr);
}
示例2: MakeNameUsable
void MakeNameUsable(char *Name,bool Extended)
{
#ifdef _WIN_ALL
// In Windows we also need to convert characters not defined in current
// code page. This double conversion changes them to '?', which is
// catched by code below.
size_t NameLength=strlen(Name);
wchar NameW[NM];
CharToWide(Name,NameW,ASIZE(NameW));
WideToChar(NameW,Name,NameLength+1);
Name[NameLength]=0;
#endif
for (char *s=Name;*s!=0;s=charnext(s))
{
if (strchr(Extended ? "?*<>|\"":"?*",*s)!=NULL || Extended && (byte)*s<32)
*s='_';
#ifdef _EMX
if (*s=='=')
*s='_';
#endif
#ifndef _UNIX
if (s-Name>1 && *s==':')
*s='_';
// Remove ' ' and '.' before path separator, but allow .\ and ..\.
if ((*s==' ' || *s=='.' && s>Name && !IsPathDiv(s[-1]) && s[-1]!='.') && IsPathDiv(s[1]))
*s='_';
#endif
}
}
示例3: GetWinLongPath
// We should return 'true' even if resulting path is shorter than MAX_PATH,
// because we can also use this function to open files with non-standard
// characters, even if their path length is normal.
bool GetWinLongPath(const wchar *Src,wchar *Dest,size_t MaxSize)
{
const wchar *Prefix=L"\\\\?\\";
const size_t PrefixLength=4;
bool FullPath=IsDiskLetter(Src) && IsPathDiv(Src[2]);
size_t SrcLength=wcslen(Src);
if (IsFullPath(Src)) // Paths in d:\path\name format.
{
if (IsDiskLetter(Src))
{
if (MaxSize<=PrefixLength+SrcLength)
return false;
wcsncpy(Dest,Prefix,PrefixLength);
wcscpy(Dest+PrefixLength,Src);
return true;
}
else
if (Src[0]=='\\' && Src[1]=='\\')
{
if (MaxSize<=PrefixLength+SrcLength+2)
return false;
wcsncpy(Dest,Prefix,PrefixLength);
wcscpy(Dest+PrefixLength,L"UNC");
wcscpy(Dest+PrefixLength+3,Src+1);
return true;
}
// We may be here only if we modify IsFullPath in the future.
return false;
}
else
{
wchar CurDir[NM];
DWORD DirCode=GetCurrentDirectory(ASIZE(CurDir)-1,CurDir);
if (DirCode==0 || DirCode>ASIZE(CurDir)-1)
return false;
if (IsPathDiv(Src[0])) // Paths in \path\name format.
{
if (MaxSize<=PrefixLength+SrcLength+2)
return false;
wcsncpy(Dest,Prefix,PrefixLength);
wcsncpy(Dest+PrefixLength,CurDir,2); // Copy drive letter 'd:'.
wcscpy(Dest+PrefixLength+2,Src);
return true;
}
else // Paths in path\name format.
{
AddEndSlash(CurDir,ASIZE(CurDir));
if (MaxSize<=PrefixLength+wcslen(CurDir)+SrcLength)
return false;
wcsncpy(Dest,Prefix,PrefixLength);
wcscpy(Dest+PrefixLength,CurDir);
wcsncatz(Dest,Src,MaxSize);
return true;
}
}
return false;
}
示例4: IsFullPath
bool IsFullPath(const char *Path)
{
char PathOnly[NM];
GetFilePath(Path,PathOnly);
if (IsWildcard(PathOnly))
return(true);
#if defined(_WIN_32) || defined(_EMX)
return(Path[0]=='\\' && Path[1]=='\\' ||
IsDiskLetter(Path) && IsPathDiv(Path[2]));
#else
return(IsPathDiv(Path[0]));
#endif
}
示例5: IsFullPath
bool IsFullPath(const wchar *Path)
{
/*
wchar PathOnly[NM];
GetFilePath(Path,PathOnly,ASIZE(PathOnly));
if (IsWildcard(PathOnly))
return true;
*/
#if defined(_WIN_ALL) || defined(_EMX)
return Path[0]=='\\' && Path[1]=='\\' || IsDiskLetter(Path) && IsPathDiv(Path[2]);
#else
return IsPathDiv(Path[0]);
#endif
}
示例6: CreatePath
bool CreatePath(const wchar *Path,bool SkipLastName)
{
if (Path==NULL || *Path==0)
return false;
#if defined(_WIN_ALL) || defined(_EMX)
uint DirAttr=0;
#else
uint DirAttr=0777;
#endif
bool Success=true;
for (const wchar *s=Path;*s!=0;s++)
{
wchar DirName[NM];
if (s-Path>=ASIZE(DirName))
break;
// Process all kinds of path separators, so user can enter Unix style
// path in Windows or Windows in Unix. s>Path check avoids attempting
// creating an empty directory for paths starting from path separator.
if (IsPathDiv(*s) && s>Path)
{
#ifdef _WIN_ALL
// We must not attempt to create "D:" directory, because first
// CreateDirectory will fail, so we'll use \\?\D:, which forces Wine
// to create "D:" directory.
if (s==Path+2 && Path[1]==':')
continue;
#endif
wcsncpy(DirName,Path,s-Path);
DirName[s-Path]=0;
Success=MakeDir(DirName,true,DirAttr)==MKDIR_SUCCESS;
#ifndef GUI
if (Success)
{
mprintf(St(MCreatDir),DirName);
mprintf(L" %s",St(MOk));
}
#endif
}
}
if (!SkipLastName && !IsPathDiv(*PointToLastChar(Path)))
Success=MakeDir(Path,true,DirAttr)==MKDIR_SUCCESS;
return Success;
}
示例7: ConvertNameToFull
void ConvertNameToFull(const char *Src,char *Dest)
{
#ifdef _WIN_32
#ifndef _WIN_CE
char FullName[NM],*NamePtr;
if (GetFullPathName(Src,sizeof(FullName),FullName,&NamePtr))
strcpy(Dest,FullName);
else
#endif
if (Src!=Dest)
strcpy(Dest,Src);
#else
char FullName[NM];
if (IsPathDiv(*Src) || IsDiskLetter(Src))
strcpy(FullName,Src);
else
{
if (getcwd(FullName,sizeof(FullName))==NULL)
*FullName=0;
else
AddEndSlash(FullName);
strcat(FullName,Src);
}
strcpy(Dest,FullName);
#endif
}
示例8: PointToName
wchar* PointToName(const wchar *Path)
{
for (int I=strlenw(Path)-1;I>=0;I--)
if (IsPathDiv(Path[I]))
return (wchar*)&Path[I+1];
return (wchar*)((*Path && IsDriveDiv(Path[1])) ? Path+2:Path);
}
示例9: CalcAllowedDepth
// Calculate a number of path components except \. and \..
static int CalcAllowedDepth(const wchar *Name)
{
int AllowedDepth=0;
while (*Name!=0)
{
if (IsPathDiv(Name[0]) && Name[1]!=0 && !IsPathDiv(Name[1]))
{
bool Dot=Name[1]=='.' && (IsPathDiv(Name[2]) || Name[2]==0);
bool Dot2=Name[1]=='.' && Name[2]=='.' && (IsPathDiv(Name[3]) || Name[3]==0);
if (!Dot && !Dot2)
AllowedDepth++;
}
Name++;
}
return AllowedDepth;
}
示例10: UnixSlashToDos
bool ScanTree::GetNextMask()
{
if (!GetFilteredMask())
return false;
#ifdef _WIN_ALL
UnixSlashToDos(CurMask,CurMask,ASIZE(CurMask));
#endif
// We wish to scan entire disk if mask like c:\ is specified
// regardless of recursion mode. Use c:\*.* mask when need to scan only
// the root directory.
ScanEntireDisk=IsDriveLetter(CurMask) && IsPathDiv(CurMask[2]) && CurMask[3]==0;
wchar *Name=PointToName(CurMask);
if (*Name==0)
wcsncatz(CurMask,MASKALL,ASIZE(CurMask));
if (Name[0]=='.' && (Name[1]==0 || Name[1]=='.' && Name[2]==0))
{
AddEndSlash(CurMask,ASIZE(CurMask));
wcsncatz(CurMask,MASKALL,ASIZE(CurMask));
}
SpecPathLength=Name-CurMask;
Depth=0;
wcsncpyz(OrigCurMask,CurMask,ASIZE(OrigCurMask));
return true;
}
示例11: ConvertNameToFull
void ConvertNameToFull(const char *Src,char *Dest)
{
#ifdef _WIN_32
//#ifndef _WIN_CE
#if !defined(_WIN_CE) && !defined(_LINUX)
char FullName[NM],*NamePtr;
if (GetFullPathName(Src,sizeof(FullName),FullName,&NamePtr))
strcpy(Dest,FullName);
else
#endif
if (Src!=Dest)
strcpy(Dest,Src);
#else
char FullName[NM];
if (IsPathDiv(*Src) || IsDiskLetter(Src))
strcpy(FullName,Src);
else
{
if (getcwd(FullName,sizeof(FullName)))
{
AddEndSlash(FullName);
strcat(FullName,Src);
}
}
strcpy(Dest,FullName);
#endif
}
示例12: ConvertPath
char* ConvertPath(const char *SrcPath,char *DestPath)
{
const char *DestPtr=SrcPath;
// Prevent \..\ in any part of path string.
for (const char *s=DestPtr;*s!=0;s++)
if (IsPathDiv(s[0]) && s[1]=='.' && s[2]=='.' && IsPathDiv(s[3]))
DestPtr=s+4;
// Remove any sequence of . and \ in the beginning of path string.
while (*DestPtr)
{
const char *s=DestPtr;
if (s[0] && IsDriveDiv(s[1]))
s+=2;
else
if (s[0]=='\\' && s[1]=='\\')
{
const char *Slash=strchr(s+2,'\\');
if (Slash!=NULL && (Slash=strchr(Slash+1,'\\'))!=NULL)
s=Slash+1;
}
for (const char *t=s;*t!=0;t++)
if (IsPathDiv(*t))
s=t+1;
else
if (*t!='.')
break;
if (s==DestPtr)
break;
DestPtr=s;
}
// Code above does not remove last "..", doing here.
if (DestPtr[0]=='.' && DestPtr[1]=='.' && DestPtr[2]==0)
DestPtr+=2;
if (DestPath!=NULL)
{
// SrcPath and DestPath can point to same memory area,
// so we use the temporary buffer for copying.
char TmpStr[NM];
strncpyz(TmpStr,DestPtr,ASIZE(TmpStr));
strcpy(DestPath,TmpStr);
}
return((char *)DestPtr);
}
示例13: PointToName
char* PointToName(const char *Path)
{
//const char *Found=NULL;
for (const char *s=&Path[strlen(Path)-1];s>=Path;s--)
if (IsPathDiv(*s))
return (char*)(s+1);
// if (Found!=NULL)
// return((char*)Found);
return (char*)((*Path && IsDriveDiv(Path[1]) && charnext(Path)==Path+1) ? Path+2:Path);
}
示例14: return
bool ScanTree::PrepareMasks()
{
ScanEntireDisk=false;
if (!FileMasks->GetString(CurMask,CurMaskW,sizeof(CurMask)))
return(false);
CurMask[ASIZE(CurMask)-1]=0;
CurMaskW[ASIZE(CurMaskW)-1]=0;
#ifdef _WIN_32
UnixSlashToDos(CurMask);
#endif
// We wish to scan entire disk if mask like c:\ is specified
// regardless of recursion mode. Use c:\*.* mask when need to scan only
// the root directory.
ScanEntireDisk=IsDiskLetter(CurMask) && IsPathDiv(CurMask[2]) && CurMask[3]==0;
char *Name=PointToName(CurMask);
if (*Name==0)
strcat(CurMask,MASKALL);
if (Name[0]=='.' && (Name[1]==0 || Name[1]=='.' && Name[2]==0))
{
AddEndSlash(CurMask);
strcat(CurMask,MASKALL);
}
SpecPathLength=Name-CurMask;
// if (SpecPathLength>1)
// SpecPathLength--;
bool WideName=(*CurMaskW!=0);
if (WideName)
{
wchar *NameW=PointToName(CurMaskW);
if (*NameW==0)
strcatw(CurMaskW,MASKALLW);
if (NameW[0]=='.' && (NameW[1]==0 || NameW[1]=='.' && NameW[2]==0))
{
AddEndSlash(CurMaskW);
strcatw(CurMaskW,MASKALLW);
}
SpecPathLengthW=NameW-CurMaskW;
}
else
{
wchar WideMask[NM];
CharToWide(CurMask,WideMask);
SpecPathLengthW=PointToName(WideMask)-WideMask;
}
Depth=0;
strcpy(OrigCurMask,CurMask);
strcpyw(OrigCurMaskW,CurMaskW);
return(true);
}
示例15: IsRelativeSymlinkSafe
bool IsRelativeSymlinkSafe(const wchar *SrcName,const wchar *TargetName)
{
if (IsFullRootPath(SrcName))
return false;
int AllowedDepth=0;
while (*SrcName!=0)
{
if (IsPathDiv(SrcName[0]) && SrcName[1]!=0 && !IsPathDiv(SrcName[1]))
{
bool Dot=SrcName[1]=='.' && (IsPathDiv(SrcName[2]) || SrcName[2]==0);
bool Dot2=SrcName[1]=='.' && SrcName[2]=='.' && (IsPathDiv(SrcName[3]) || SrcName[3]==0);
if (!Dot && !Dot2)
AllowedDepth++;
}
SrcName++;
}
if (IsFullRootPath(TargetName)) // Catch root dir based /path/file paths.
return false;
for (int Pos=0;*TargetName!=0;Pos++)
{
bool Dot2=TargetName[0]=='.' && TargetName[1]=='.' &&
(IsPathDiv(TargetName[2]) || TargetName[2]==0) &&
(Pos==0 || IsPathDiv(*(TargetName-1)));
if (Dot2)
AllowedDepth--;
TargetName++;
}
return AllowedDepth>=0;
}