nucleuspdirectory.cxx

来自「opal的ptlib c++源程序 可以从官方网站上下载」· CXX 代码 · 共 78 行

CXX
78
字号
#include <ptlib.h>

void PDirectory::Construct ()

{
#ifdef __NUCLEUS_PLUS__
PAssertAlways("No PDirectories under Nucleus");
#else
  directory   = NULL;
  entryBuffer = NULL;
  entryInfo   = NULL;

  PString::operator =(CanonicaliseDirectory(*this));
#endif
}

void PDirectory::Close()
{
#ifdef __NUCLEUS_PLUS__
PAssertAlways("No PDirectories under Nucleus");
#else
  if (directory != NULL) {
    PAssert(closedir(directory) == 0, POperatingSystemError);
    directory = NULL;
  }

  if (entryBuffer != NULL) {
    free(entryBuffer);
    entryBuffer = NULL;
  }

  if (entryInfo != NULL) {
    delete entryInfo;
    entryInfo = NULL;
  }
#endif
}

void PDirectory::CopyContents(const PDirectory & d)
{
#ifdef __NUCLEUS_PLUS__
PAssertAlways("No PDirectories under Nucleus");
#else
  if (d.entryInfo == NULL)
    entryInfo = NULL;
  else {
    entryInfo  = new PFileInfo;
    *entryInfo = *d.entryInfo;
  }
  directory   = NULL;
  entryBuffer = NULL;
#endif
}

PBoolean PDirectory::Create(const PString & p, int perm)
{
#ifdef __NUCLEUS_PLUS__
PAssertAlways("No PDirectories under Nucleus");
return PTrue;
#else
  PAssert(!p.IsEmpty(), "attempt to create dir with empty name");
  PString str = p.Left(p.GetLength()-1);
  return mkdir(str, perm) == 0;
#endif
}

PBoolean PDirectory::Remove(const PString & p)
{
#ifdef __NUCLEUS_PLUS__
PAssertAlways("No PDirectories under Nucleus");
return PTrue;
#else
  PAssert(!p.IsEmpty(), "attempt to remove dir with empty name");
  PString str = p.Left(p.GetLength()-1);
  return rmdir(str) == 0;
#endif
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?