示例#1
0
Dir::Dir(const String& path)
    : _path(path)
{

#ifdef PEGASUS_OS_OS400
    CString tmpPathclone = _clonePath(_path);
    const char* tmpPath = tmpPathclone;
    OS400_PNSTRUCT pathname;
    memset((void*)&pathname, 0x00, sizeof(OS400_PNSTRUCT));
    pathname.qlg_struct.CCSID = 1208;
#pragma convert(37)
    memcpy(pathname.qlg_struct.Country_ID,"US",2);
    memcpy(pathname.qlg_struct.Language_ID,"ENU",3);
#pragma convert(0)
    pathname.qlg_struct.Path_Type = QLG_PTR_SINGLE;
    pathname.qlg_struct.Path_Length = strlen(tmpPath);
    pathname.qlg_struct.Path_Name_Delimiter[0] = '/';
    pathname.pn = (char *)tmpPath;
    _dirRep.dir = QlgOpendir((Qlg_Path_Name_T *)&pathname);
#else
    _dirRep.dir = opendir(_clonePath(_path));
#endif
    if (_dirRep.dir)
    {
#ifdef PEGASUS_HAS_READDIR_R
	// Need to use readdir_r since we are multithreaded
#ifdef PEGASUS_OS_OS400
	if (QlgReaddir_r(_dirRep.dir, &_dirRep.buffer, &_dirRep.entry) != 0)
#else
	if (readdir_r(_dirRep.dir, &_dirRep.buffer, &_dirRep.entry) != 0)
#endif
        {
	    _more = false;
            closedir(_dirRep.dir);
	    throw CannotOpenDirectory(_path);
        }
#else
	_dirRep.entry = readdir(_dirRep.dir);
#endif
	_more = _dirRep.entry != NULL;
    }
    else
    {
	_more = false;
	throw CannotOpenDirectory(_path);
    }
}
示例#2
0
Boolean FileSystem::existsNoCase(const String& path, String& realPath)
{
#if !defined(PEGASUS_OS_VMS) && \
    !defined(PEGASUS_OS_TYPE_WINDOWS) && \
    !defined(PEGASUS_OS_DARWIN)

    // If a file exists that has the same case as the path parmater,
    // then we can bypass the expensive directory scanning below.

    if (FileSystem::exists(path))
    {
        realPath = path;
        return true;
    }

#endif

    realPath.clear();
    CString cpath = _clonePath(path);
    const char* p = cpath;

    const char* dirPath;
    const char* fileName;
    char* slash = (char *) strrchr(p, '/');

    if (slash)
    {
        *slash = '\0';
        fileName = slash + 1;
        dirPath = p;

        if (*fileName == '\0')
            return false;
    }
    else
    {
        fileName = p;
        dirPath = ".";
    }


    for (Dir dir(dirPath); dir.more(); dir.next())
    {
        if (System::strcasecmp(fileName, dir.getName()) == 0)
        {
            if (strcmp(dirPath, ".") == 0)
                realPath = dir.getName();
            else
            {
                realPath = dirPath;
                realPath.append('/');
                realPath.append(dir.getName());
            }
            return true;
        }
    }

    return false;
}
示例#3
0
Boolean FileSystem::exists(const String& path)
{
    return System::exists(_clonePath(path));
}
示例#4
0
Boolean FileSystem::removeFile(const String& path)
{
    return System::removeFile(_clonePath(path));
}
示例#5
0
Boolean FileSystem::getFileSize(const String& path, Uint32& size)
{
    return System::getFileSize(_clonePath(path), size);
}
示例#6
0
Boolean FileSystem::canWrite(const String& path)
{
    return System::canWrite(_clonePath(path));
}
示例#7
0
Boolean FileSystem::canRead(const String& path)
{
    return System::canRead(_clonePath(path));
}