当前位置: 首页>>代码示例>>C++>>正文


C++ plFileName类代码示例

本文整理汇总了C++中plFileName的典型用法代码示例。如果您正苦于以下问题:C++ plFileName类的具体用法?C++ plFileName怎么用?C++ plFileName使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了plFileName类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: fFileSize

/* plFileInfo */
plFileInfo::plFileInfo(const plFileName &filename)
    : fFileSize(-1), fCreateTime(), fModifyTime(), fFlags()
{
    if (!filename.IsValid())
        return;

#if HS_BUILD_FOR_WIN32
    struct __stat64 info;
    if (_wstat64(filename.AsString().ToWchar(), &info) != 0)
        return;
#else
    struct stat info;
    if (stat(filename.AsString().c_str(), &info) != 0)
        return;
#endif

    fFlags |= kEntryExists;
    fFileSize = info.st_size;
    fCreateTime = info.st_ctime;
    fModifyTime = info.st_mtime;
    if (info.st_mode & S_IFDIR)
        fFlags |= kIsDirectory;
    if (info.st_mode & S_IFREG)
        fFlags |= kIsNormalFile;
}
开发者ID:Filtik,项目名称:Plasma,代码行数:26,代码来源:plFileSystem.cpp

示例2: SetCWD

bool plFileSystem::SetCWD(const plFileName &cwd)
{
#if HS_BUILD_FOR_WIN32
    return SetCurrentDirectoryW(cwd.AsString().ToWchar());
#else
    return (chdir(cwd.AsString().c_str()) == 0);
#endif
}
开发者ID:Filtik,项目名称:Plasma,代码行数:8,代码来源:plFileSystem.cpp

示例3: Move

bool plFileSystem::Move(const plFileName &from, const plFileName &to)
{
#if HS_BUILD_FOR_WIN32
    return MoveFileExW(from.AsString().ToWchar(), to.AsString().ToWchar(),
                       MOVEFILE_REPLACE_EXISTING);
#else
    if (!Copy(from, to))
        return false;
    return Unlink(from);
#endif
}
开发者ID:Filtik,项目名称:Plasma,代码行数:11,代码来源:plFileSystem.cpp

示例4: Unlink

bool plFileSystem::Unlink(const plFileName &filename)
{
#if HS_BUILD_FOR_WIN32
    plStringBuffer<wchar_t> wfilename = filename.AsString().ToWchar();
    _wchmod(wfilename, S_IWRITE);
    return _wunlink(wfilename) == 0;
#else
    chmod(filename.AsString().c_str(), S_IWRITE);
    return unlink(filename.AsString().c_str()) == 0;
#endif
}
开发者ID:Filtik,项目名称:Plasma,代码行数:11,代码来源:plFileSystem.cpp

示例5: AutoExportDir

static bool AutoExportDir(const char* inputDir, const char* outputDir, const plFileName& groupFiles, std::vector<plFileName>& excludeFiles)
{
    bool exportedFile = false;

    char outputFileName[MAX_PATH];
    sprintf(outputFileName, "%s\\Export.prd", outputDir);

    char outputLog[MAX_PATH];
    sprintf(outputLog, "%s\\AutoExport.log", outputDir);
    
    char doneDir[MAX_PATH];
    sprintf(doneDir, "%s\\Done\\", inputDir);
    CreateDirectory(doneDir, NULL);

    // Don't give missing bitmap warnings
    TheManager->SetSilentMode(TRUE);

    std::vector<plFileName> sources = plFileSystem::ListDir(inputDir, "*.max");
    for (auto iter = sources.begin(); iter != sources.end(); ++iter)
    {
        if (IsExcluded(iter->GetFileName(), excludeFiles))
            continue;

        // If we're doing grouped files, and this isn't one, keep looking
        if (groupFiles.IsValid() && groupFiles != iter->GetFileName())
            continue;

        hsUNIXStream log;
        if (log.Open(outputLog, "ab"))
        {
            log.WriteFmt("%s\r\n", iter->GetFileName().c_str());
            log.Close();
        }

        if (GetCOREInterface()->LoadFromFile(iter->AsString().c_str()))
        {
            plFileSystem::Move(*iter, plFileName::Join(inputDir, "Done", iter->GetFileName()));

            GetCOREInterface()->ExportToFile(outputFileName, TRUE);
            exportedFile = true;

            // If we're not doing grouped files, this is it, we exported our one file
            if (!groupFiles.IsValid())
                break;
        }
    }

    return exportedFile;
}
开发者ID:MareinK,项目名称:Plasma,代码行数:49,代码来源:plExportDlg.cpp

示例6: WhitelistFile

void pfPatcherWorker::WhitelistFile(const plFileName& file, bool justDownloaded, hsStream* stream)
{
    // if this is a newly downloaded file, fire off a completion callback
    if (justDownloaded && fFileDownloaded)
        fFileDownloaded(file);

    // we want to whitelist our game code, so here we go...
    if (fGameCodeDiscovered) {
        plString ext = file.GetFileExt();
        if (ext.CompareI("pak") == 0 || ext.CompareI("sdl") == 0) {
            if (!stream) {
                stream = new hsUNIXStream;
                stream->Open(file, "rb");
            }

            // if something terrible goes wrong (eg bad encryption), we can exit sanely
            // callback eats stream
            if (!fGameCodeDiscovered(file, stream))
                EndPatch(kNetErrInternalError, "SecurePreloader failed.");
        }
    } else if (stream) {
        // no dad gum memory leaks, m'kay?
        stream->Close();
        delete stream;
    }
}
开发者ID:JECervini,项目名称:Plasma,代码行数:26,代码来源:pfPatcher.cpp

示例7: hsGlobalSemaphore

plStatusLog::plStatusLog( uint8_t numDisplayLines, const plFileName &filename, uint32_t flags )
{
    fFileHandle = nil;
    fSema = nil;
    fSize = 0;
    fForceLog = false;

    fMaxNumLines = numDisplayLines;
    if (filename.IsValid())
    {
        fFilename = filename;
        fSema = new hsGlobalSemaphore(1, fFilename.AsString().c_str());
    }
    else
    {
        fFilename = "";
        flags |= kDontWriteFile;

        fSema = new hsGlobalSemaphore(1);
    }

    fOrigFlags = fFlags = flags;

    IInit();
}
开发者ID:Drakesinger,项目名称:Plasma,代码行数:25,代码来源:plStatusLog.cpp

示例8: GetFullPath

static plFileName GetFullPath(const plFileName &filename)
{
    if (filename.StripFileName().IsValid())
        return filename;

    return plFileName::Join("sfx", filename);
}
开发者ID:Filtik,项目名称:Plasma,代码行数:7,代码来源:plSoundBuffer.cpp

示例9: hsAssert

std::vector<plFileName> plStreamSource::GetListOfNames(const plFileName& dir, const plString& ext)
{
    plFileName sDir = dir.Normalize('/');
    hsAssert(ext.CharAt(0) != '.', "Don't add a dot");
    std::lock_guard<std::mutex> lock(fMutex);

    // loop through all the file data records, and create the list
    std::vector<plFileName> retVal;
    for (auto curData = fFileData.begin(); curData != fFileData.end(); curData++)
    {
        if ((curData->second.fDir.AsString().CompareI(sDir.AsString()) == 0) &&
            (curData->second.fExt.CompareI(ext) == 0))
            retVal.push_back(curData->second.fFilename);
    }

#ifndef PLASMA_EXTERNAL_RELEASE
    // in internal releases, we can use on-disk files if they exist
    // Build the search string as "dir/*.ext"
    std::vector<plFileName> files = plFileSystem::ListDir(sDir, ("*." + ext).c_str());
    for (auto iter = files.begin(); iter != files.end(); ++iter)
    {
        plFileName norm = iter->Normalize('/');
        if (fFileData.find(norm) == fFileData.end()) // we haven't added it yet
            retVal.push_back(norm);
    }
#endif // PLASMA_EXTERNAL_RELEASE

    return retVal;
}
开发者ID:Drakesinger,项目名称:Plasma,代码行数:29,代码来源:plStreamSource.cpp

示例10: memset

plFileName plBrowseFolder::GetFolder(const plFileName &startPath, const ST::string &title, HWND hwndOwner)
{
    BROWSEINFOW bi;
    memset(&bi, 0, sizeof(bi));
    ST::wchar_buffer titleW = title.to_wchar();
    ST::wchar_buffer startPathW = startPath.WideString();
    bi.hwndOwner    = hwndOwner;
    bi.lpszTitle    = titleW.data();
    bi.lpfn         = BrowseCallbackProc;
    bi.lParam       = (LPARAM) startPathW.data();

    LPITEMIDLIST iil = SHBrowseForFolderW(&bi);
    plFileName path;
    if (!iil) {
        // Browse failed, or cancel was selected
        path = ST::null;
    } else {
        // Browse succeded.  Get the path.
        wchar_t buffer[MAX_PATH];
        SHGetPathFromIDListW(iil, buffer);
        path = ST::string::from_wchar(buffer);
    }

    // Free the memory allocated by SHBrowseForFolder
    LPMALLOC pMalloc;
    SHGetMalloc(&pMalloc);
    pMalloc->Free(iil);
    pMalloc->Release();

    return path;
}
开发者ID:H-uru,项目名称:Plasma,代码行数:31,代码来源:plBrowseFolder.cpp

示例11: IAuthThingDownloadCB

static void IAuthThingDownloadCB(ENetError result, void* param, const plFileName& filename, hsStream* writer)
{
    pfPatcherWorker* patcher = static_cast<pfPatcherWorker*>(param);

    if (IS_NET_SUCCESS(result)) {
        PatcherLogGreen("\tDownloaded Legacy File '%s'", filename.AsString().c_str());
        patcher->IssueRequest();

        // Now, we pass our RAM-backed file to the game code handlers. In the main client,
        // this will trickle down and add a new friend to plStreamSource. This should never
        // happen in any other app...
        writer->Rewind();
        patcher->WhitelistFile(filename, true, writer);
    } else {
        PatcherLogRed("\tDownloaded Failed: File '%s'", filename.AsString().c_str());
        patcher->EndPatch(result, filename.AsString());
    }
}
开发者ID:JECervini,项目名称:Plasma,代码行数:18,代码来源:pfPatcher.cpp

示例12: pfPatcherStream

 pfPatcherStream(pfPatcherWorker* parent, const plFileName& filename, const NetCliFileManifestEntry& entry)
     : fParent(parent), fFlags(entry.flags), fBytesWritten(0)
 {
     // ugh. eap removed the compressed flag in his fail manifests
     if (filename.GetFileExt().CompareI("gz") == 0) {
         fFlags |= pfPatcherWorker::kFlagZipped;
         parent->fTotalBytes += entry.zipSize;
     } else
         parent->fTotalBytes += entry.fileSize;
 }
开发者ID:JECervini,项目名称:Plasma,代码行数:10,代码来源:pfPatcher.cpp

示例13: GetUserDataPath

plFileName plFileSystem::GetUserDataPath()
{
    static plFileName _userData;

    if (!_userData.IsValid()) {
#if HS_BUILD_FOR_WIN32
        wchar_t path[MAX_PATH];
        if (!SHGetSpecialFolderPathW(NULL, path, CSIDL_LOCAL_APPDATA, TRUE))
            return "";

        _userData = plFileName::Join(plString::FromWchar(path), plProduct::LongName());
#else
        _userData = plFileName::Join(getenv("HOME"), "." + plProduct::LongName());
#endif
        plFileSystem::CreateDir(_userData);
    }

    return _userData;
}
开发者ID:Filtik,项目名称:Plasma,代码行数:19,代码来源:plFileSystem.cpp

示例14: LoadAvatar

plKey plAvatarMgr::LoadAvatar(plString name, plString accountName, bool isPlayer, plKey spawnPoint, plAvTask *initialTask,
                              const plString &userStr, const plFileName &clothingFile)
{
    // *** account is currently unused. the idea is that eventually an NPC will
    // *** be able to use a customization account
    plKey result = nullptr;
    plKey requestor = GetKey(); // avatar manager is always the requestor for avatar loads
    plNetClientMgr *netMgr = plNetClientMgr::GetInstance();

    if(netMgr)      // can't clone without the net manager
    {
        hsAssert(!name.IsEmpty(), "name required by LoadPlayer fxn");
        netMgr->DebugMsg("Local: Loading player %s", name.c_str());

        // look up player by key name provided by user.
        // this string search should be replaced with some other method of 
        // avatar selection and key lookup.

        // Get the location for the player first
        plKey playerKey = nullptr;
        const plLocation& globalLoc = plKeyFinder::Instance().FindLocation("GlobalAvatars", name);
        const plLocation& maleLoc = plKeyFinder::Instance().FindLocation("GlobalAvatars", "Male");
        const plLocation& custLoc = plKeyFinder::Instance().FindLocation("CustomAvatars", name);

#ifdef PLASMA_EXTERNAL_RELEASE
        // Try global. If that doesn't work, players default to male.
        // If not a player, try custLoc. If that doesn't work, fall back to male
        const plLocation& loc = (globalLoc.IsValid() ? globalLoc : isPlayer ? maleLoc : custLoc.IsValid() ? custLoc : maleLoc);
#else
        // Try global. If that doesn't work try custom. Otherwise fall back to male
        const plLocation& loc = (globalLoc.IsValid() ? globalLoc : custLoc.IsValid() ? custLoc : maleLoc);
#endif

        if (loc == maleLoc)
            name = "Male";

        if (loc.IsValid())
        {
            plUoid uID(loc, plSceneObject::Index(), name);
            plLoadAvatarMsg *cloneMsg = new plLoadAvatarMsg(uID, requestor, 0, isPlayer, spawnPoint, initialTask, userStr);
            if (clothingFile.IsValid())
            {
                plLoadClothingMsg *clothingMsg = new plLoadClothingMsg(clothingFile);
                cloneMsg->SetTriggerMsg(clothingMsg);
            }
            result =  cloneMsg->GetCloneKey();
            
            // the clone message is automatically addressed to the net client manager
            // we'll receive the message back (or a similar message) when the clone is loaded
            cloneMsg->Send();
        }
    }
    return result;
}
开发者ID:Drakesinger,项目名称:Plasma,代码行数:54,代码来源:plAvatarMgr.cpp

示例15: Join

plFileName plFileName::Join(const plFileName &base, const plFileName &path)
{
    if (!base.IsValid())
        return path;
    if (!path.IsValid())
        return base;

    char last = base.fName.CharAt(base.GetSize() - 1);
    char first = path.fName.CharAt(0);
    if (last != '/' && last != '\\') {
        if (first != '/' && first != '\\') {
            return plString::Format("%s" PATH_SEPARATOR_STR "%s",
                                    base.fName.c_str(), path.fName.c_str());
        }
        return base.fName + path.fName;
    } else if (first != '/' && first != '\\') {
        return base.fName + path.fName;
    }
    // Both have a slash, but we only need one
    return base.fName + path.fName.Substr(1);
}
开发者ID:Filtik,项目名称:Plasma,代码行数:21,代码来源:plFileSystem.cpp


注:本文中的plFileName类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。