本文整理汇总了C++中Pathname::IsNull方法的典型用法代码示例。如果您正苦于以下问题:C++ Pathname::IsNull方法的具体用法?C++ Pathname::IsNull怎么用?C++ Pathname::IsNull使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pathname
的用法示例。
在下文中一共展示了Pathname::IsNull方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FullToRelative
bool Pathname::FullToRelative(const Pathname &relativeto)
{
if (relativeto.IsNull() || IsNull()) return false;
bool h1= HasDrive();
bool h2= relativeto.HasDrive();
if (h1 != h2) return false; //rozdilny zpusob adresace - nelze vytvorit relatvni cestu
if (h1== true && h2== true && toupper(GetDrive()) != toupper(relativeto.GetDrive()))
return false; //ruzne disky, nelze vytvorit relativni cestu
if (strncmp(_path,"\\\\",2) == 0) //sitova cesta
{
int slsh = 0; //citac lomitek
const char *a = _path;
const char *b = relativeto._path;
while (toupper(*a) == toupper(*b) && *a && slsh<3) //zacatek sitove cesty musi byt stejny
{
if (*a =='\\') slsh++;
a++;b++;
}
if (slsh != 3) return false; //pokud neni stejny, nelze vytvorit relativni cestu
}
int sublevel = 0;
const char *ps1= _path;
const char *ps2= relativeto._path;
if (h1)
{ps1 += 2;ps2 += 2;}
const char *sls = ps2;
while (toupper(*ps1) == toupper(*ps2) && *ps1)
{
if (*ps2=='\\') sls = ps2+1;
ps1++;ps2++;
}
ps1 -= ps2-sls;
if (sls)
{
while (sls = strchr(sls,'\\'))
{
sls++;
sublevel++;
}
}
char *buff = (char *)alloca((sublevel*3+strlen(ps1)+1)*sizeof(*buff));
char *pos = buff;
for (int i = 0;i<sublevel;i++)
{strcpy(pos,"..\\");pos += 3;}
strcpy(pos,ps1);
SetDrive(0);
SetDirectory(buff);
return true;
}
示例2: RelativeToFull
bool Pathname::RelativeToFull(const Pathname &ref)
{
if (ref.IsNull() || IsNull()) return false;
const char *beg;
if (HasDrive())
if (toupper(GetDrive()) != toupper(ref.GetDrive())) return false;
else beg = _path+2;
else beg = _path;
const char *end = strchr(ref._path,0);
if (beg[0] =='\\')
{
int np;
if (ref.HasDrive()) end = ref._path+2;
else if (np = ref.IsNetworkPath()) end = ref._path+np;
else end = ref._path;
}
else while (strncmp(beg,"..\\",3) == 0 || strncmp(beg,".\\",2) == 0)
{
if (beg[1] =='.')
{
if (end>ref._path)
{
end--;
while (end>ref._path && end[-1]!='\\') end--;
}
beg += 3;
}
else
beg += 2;
}
int partln = end-ref._path;
char *buff = (char *)alloca((partln+strlen(beg)+1)*sizeof(*buff));
memcpy(buff,ref._path,partln);
strcpy(buff+partln,beg);
SetDrive(0);
SetDirectory(buff);
return true;
}
示例3: RebuildData
Pathname::Pathname(const Pathname &other)
{
_fullpath = NULL;
if (other.IsNull()) SetNull();
else RebuildData(other._path,other._filetitle,other._extension,strlen(other._path),strlen(other._filetitle),strlen(other._extension));
}