• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ plFileName类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: IInitDlg

void plExportDlgImp::IInitDlg(HWND hDlg)
{
    // Set the client path
    plFileName path = plMaxConfig::GetClientPath(false, true);
    SetDlgItemText(hDlg, IDC_CLIENT_PATH, path.AsString().c_str());

    // Set the preshade button
    CheckDlgButton(hDlg, IDC_PRESHADE_CHECK, fPreshade ? BST_CHECKED : BST_UNCHECKED);
    CheckDlgButton(hDlg, IDC_PHYSICAL_CHECK, fPhysicalsOnly ? BST_CHECKED : BST_UNCHECKED);
    CheckDlgButton(hDlg, IDC_LIGHTMAP_CHECK, fLightMap ? BST_CHECKED : BST_UNCHECKED);

    char buf[256];
    sprintf(buf, "Last export took %d:%02d", fLastExportTime/60, fLastExportTime%60);
    SetDlgItemText(hDlg, IDC_LAST_EXPORT, buf);

    SetWindowPos(hDlg, NULL, fXPos, fYPos, 0, 0, SWP_NOSIZE | SWP_NOZORDER);

    //
    // Get the names of all the pages in this scene and put them in the combo
    //
    HWND hPages = GetDlgItem(hDlg, IDC_PAGE_COMBO);
    ComboBox_AddString(hPages, kAllPages);

    bool foundPage = false;

    CompSet comps;
    GetPagesRecur((plMaxNode*)GetCOREInterface()->GetRootNode(), comps);
    for (CompSet::iterator it = comps.begin(); it != comps.end(); it++)
    {
        const char* page = LocCompGetPage(*it);
        if (page)
        {
            int idx = ComboBox_AddString(hPages, page);
            if (!strcmp(page, fExportPage))
            {
                foundPage = true;
                ComboBox_SetCurSel(hPages, idx);
            }
        }
    }

    if (!foundPage)
    {
        fExportPage[0] = '\0';
        ComboBox_SetCurSel(hPages, 0);
    }

    CheckRadioButton(hDlg, IDC_RADIO_FILE, IDC_RADIO_DIR, IDC_RADIO_FILE);
    IGetRadio(hDlg);

    SetDlgItemTextW(hDlg, IDC_EXPORT_PATH, fExportSourceDir.AsString().ToWchar());
}
开发者ID:MareinK,项目名称:Plasma,代码行数:52,代码来源:plExportDlg.cpp


示例17: Copy

bool plFileSystem::Copy(const plFileName &from, const plFileName &to)
{
#if HS_BUILD_FOR_WIN32
    return CopyFileW(from.AsString().ToWchar(), to.AsString().ToWchar(), FALSE);
#else
    typedef std::unique_ptr<FILE, std::function<int (FILE *)>> _FileRef;

    _FileRef ffrom(Open(from, "rb"), fclose);
    _FileRef fto(Open(to, "wb"), fclose);
    if (!ffrom.get() || !fto.get())
        return false;

    size_t count;
    uint8_t buffer[4096];
    while (!feof(ffrom.get())) {
        count = fread(buffer, sizeof(uint8_t), arrsize(buffer), ffrom.get());
        if (ferror(ffrom.get()))
            return false;
        fwrite(buffer, sizeof(uint8_t), count, fto.get());
    }

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


示例18: FindFirstFileW

std::vector<plFileName> plFileSystem::ListDir(const plFileName &path, const char *pattern)
{
    std::vector<plFileName> contents;

#if HS_BUILD_FOR_WIN32
    if (!pattern || !pattern[0])
        pattern = "*";
    plFileName searchPattern = plFileName::Join(path, pattern);

    WIN32_FIND_DATAW findData;
    HANDLE hFind = FindFirstFileW(searchPattern.AsString().ToWchar(), &findData);
    if (hFind == INVALID_HANDLE_VALUE)
        return contents;

    do {
        if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
            // Should also handle . and ..
            continue;
        }

        contents.push_back(plFileName::Join(path, plString::FromWchar(findData.cFileName)));
    } while (FindNextFileW(hFind, &findData));

    FindClose(hFind);
#else
    DIR *dir = opendir(path.AsString().c_str());
    if (!dir)
        return contents;

    struct dirent *de;
    while (de = readdir(dir)) {
        plFileName dir_name = plFileName::Join(path, de->d_name);
        if (plFileInfo(dir_name).IsDirectory()) {
            // Should also handle . and ..
            continue;
        }

        if (pattern && pattern[0] && fnmatch(pattern, de->d_name, 0))
            contents.push_back(dir_name);
        else if (!pattern || !pattern[0])
            contents.push_back(dir_name);
    }

    closedir(dir);
#endif

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


示例19: InsertFile

bool plStreamSource::InsertFile(const plFileName& filename, hsStream* stream)
{
    plFileName sFilename = filename.Normalize('/');

    std::lock_guard<std::mutex> lock(fMutex);
    if (fFileData.find(sFilename) != fFileData.end())
        return false; // duplicate entry, return failure

    // copy the data over (takes ownership of the stream!)
    fFileData[sFilename].fFilename = sFilename;
    fFileData[sFilename].fDir = sFilename.StripFileName();
    fFileData[sFilename].fExt = sFilename.GetFileExt();
    fFileData[sFilename].fStream = stream;

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


示例20: hsAssert

plBufferedFileReader::plBufferedFileReader( const plFileName &path, plAudioCore::ChannelSelect whichChan )
{
    // Init some stuff
    fBufferSize = 0;
    fBuffer = nil;
    fCursor = 0;

    hsAssert( path.IsValid(), "Invalid path specified in plBufferedFileReader" );

    // Ask plAudioFileReader for another reader to get this file
    // Note: have this reader do the chanSelect for us
    plAudioFileReader *reader = plAudioFileReader::CreateReader( path, whichChan );
    if( reader == nil || !reader->IsValid() )
    {
        delete reader;
        IError( "Unable to open file to read in to RAM buffer" );
        return;
    }

    fHeader = reader->GetHeader();

    fBufferSize = reader->GetDataSize();
    fBuffer = new uint8_t[ fBufferSize ];
    //plProfile_NewMem( SndBufferedMem, fBufferSize );
    if( fBuffer == nil )
    {
        delete reader;
        IError( "Unable to allocate RAM buffer" );
        return;
    }

    if( !reader->Read( fBufferSize, fBuffer ) )
    {
        delete reader;
        IError( "Unable to read file into RAM buffer" );
        return;
    }

    // All done!
    delete reader;
}
开发者ID:Asteral,项目名称:Plasma,代码行数:41,代码来源:plBufferedFileReader.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ plKey类代码示例发布时间:2022-05-31
下一篇:
C++ phpret类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap