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


C++ TPath类代码示例

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


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

示例1: Move

TError TMount::Move(TPath destination) {
    int ret = mount(Target.ToString().c_str(), destination.ToString().c_str(), NULL, MS_MOVE, NULL);
    if (ret)
        return TError(EError::Unknown, errno, "mount(" + Target.ToString() + ", " + destination.ToString() + ", MS_MOVE)");
    Target = destination;
    return TError::Success();
}
开发者ID:presto53,项目名称:porto,代码行数:7,代码来源:mount.cpp

示例2: AddDrivePathsL

// ---------------------------------------------------------------------------
// CAknMemorySelectionDialogMultiDrive::AddDrivePathsL
// ---------------------------------------------------------------------------
//
EXPORT_C TInt CAknMemorySelectionDialogMultiDrive::AddDrivePathsL(
    const TDesC& aRootPath,
    const TDesC& aDefaultFolder
    )
    {
    // TODO: Verify paramters if they are valid.
    TInt rootPathCount=iRootPathArray.Count();
    TInt result = KErrNone;
    TPath path;
    for ( TInt i=0;i<rootPathCount;i++ )
        {
        path.Copy( iRootPathArray[i] );
        path.Append( aRootPath );
        AknCFDUtility::AddTrailingBackslash( path );
        iRootPathArray.Delete(i);
        iRootPathArray.Compress();
        iRootPathArray.InsertL( i, path );
        path.Copy( aDefaultFolder );
        AknCFDUtility::AddTrailingBackslash( path );
        iDefaultFolderArray.Delete(i);
        iDefaultFolderArray.Compress();
        iDefaultFolderArray.InsertL( i, path );
        }
    return result;
    }
开发者ID:cdaffara,项目名称:symbiandump-mw1,代码行数:29,代码来源:caknmemoryselectiondialogmultidrive.cpp

示例3: DirName

bool TPath::HasAccess(const TCred &cred, enum Access mask) const {
    struct stat st;
    int mode;

    if (!cred.Uid && !access(c_str(), mask & TPath::RWX))
        return true;

    if (stat(c_str(), &st)) {
        if (!(mask & TPath::P) || errno != ENOENT)
            return false;
        TPath dir = DirName();
        while (stat(dir.c_str(), &st)) {
            if (errno != ENOENT)
                return false;
            if (dir.Path.size() <= 1)
                return false;
            dir = dir.DirName();
        }
    }

    if ((mask & TPath::U) && cred.Uid == st.st_uid)
        return true;

    if (cred.Uid == st.st_uid)
        mode = st.st_mode >> 6;
    else if (cred.IsMemberOf(st.st_gid))
开发者ID:noxiouz,项目名称:porto,代码行数:26,代码来源:path.cpp

示例4: Open

TError TNamespaceFd::Open(TPath path) {
    Close();
    Fd = open(path.c_str(), O_RDONLY | O_NOCTTY | O_NONBLOCK | O_CLOEXEC);
    if (Fd < 0)
        return TError(EError::Unknown, errno, "Cannot open " + path.ToString());
    return TError::Success();
}
开发者ID:direvius,项目名称:porto,代码行数:7,代码来源:namespace.cpp

示例5: testRescaleImageSuccefully

void T_CntImageRescaler::testRescaleImageSuccefully()
    {
    test.Next(_L("Rescale image"));

    TPath dest;
    dest.Append(KDestDir());
    dest.Append(_L("test.jpg"));

    TTime time;
    time.UniversalTime();

    TRAPD(err, iRescaler->ResizeImageL(KSrcImage(), dest));

    TTime time2;
    time2.UniversalTime();

    TInt seconds = time2.MicroSecondsFrom( time ).Int64() / 1000000;

    test.Printf(_L("rescaled in %d seconds\n"), seconds);

    test(err == KErrNone);
    test(BaflUtils::FileExists(iFs, dest));

    TEntry file;
    if (iFs.Entry(dest, file) == KErrNone)
        {
        test(file.iSize <= KMaxImageSize);
        }
    }
开发者ID:Esclapion,项目名称:qt-mobility,代码行数:29,代码来源:t_cntimagerescaler.cpp

示例6: GetNewNameForFileDigit

	TString GetNewNameForFileDigit(const TPath &oldPath, const TString &nameWithoutDigit, __int64 & counter, size_t & leadingZeros, const TPath &pathForRename)
    {
		TString pathWithDigit;
		const int BUFFER_SIZE = 65;
		char buffer[BUFFER_SIZE];
		TString leadingZeroString;

		counter++;
		if (leadingZeros > 0)
		{
			if (LengthOfLong(counter) > LengthOfLong(counter - 1)) //если цифра удленилась
               leadingZeros--;
			for (size_t i = 0; i < leadingZeros; i++)
				leadingZeroString.push_back('0');
		}

		if (_i64toa_s(counter, buffer, BUFFER_SIZE, 10) == 0)
		{
			pathWithDigit = CreatePath(oldPath.GetDirectory(), nameWithoutDigit + leadingZeroString + TString(buffer) + oldPath.GetExtension());
			if(TPath::EqualByNameWithExtension(pathWithDigit, pathForRename))
				return pathForRename.Original();
			if (IsFileExists(pathWithDigit.c_str())) //если такой файл уже есть, то не увеличиваем номер, а добавляем _2
				return GetNewNameForFileAdd(oldPath);
		}
		else
			return GetNewNameForFileAdd(oldPath);
		return pathWithDigit;
    }
开发者ID:flying19880517,项目名称:AntiDupl,代码行数:28,代码来源:adFileUtils.cpp

示例7: ReadLink

std::string ReadLink(const std::string &path) {
    TPath lnk;

    TPath f(path);
    TError error = f.ReadLink(lnk);
    if (error)
        throw error.GetMsg();

    return lnk.ToString();
}
开发者ID:noxiouz,项目名称:porto,代码行数:10,代码来源:test.cpp

示例8: CreateTmpDir

TError TTask::CreateTmpDir(const TPath &path, std::shared_ptr<TFolder> &dir) const {
    bool cleanup = path.ToString().find(config().container().tmp_dir()) == 0;

    dir = std::make_shared<TFolder>(path, cleanup);
    if (!dir->Exists()) {
        TError error = dir->Create(0755, true);
        if (error)
            return error;
        error = path.Chown(Env->Cred.Uid, Env->Cred.Gid);
        if (error)
            return error;
    }

    return TError::Success();
}
开发者ID:presto53,项目名称:porto,代码行数:15,代码来源:task.cpp

示例9: GetNewNameForFileAdd

	// Перименовываем, добавляя _2 к имени файла.
	TString GetNewNameForFileAdd(const TPath &oldPath)
    {
		TString uniquePath;
		const int SIMILAR_PREFIX_SIZE = 16;
		const TChar *SIMILAR_PREFIX_FORMAT = TEXT("_%u");
		TChar buffer[SIMILAR_PREFIX_SIZE];
		unsigned long counter = 2;

		do 
		{
			_stprintf_s(buffer, SIMILAR_PREFIX_FORMAT, counter++);
			uniquePath = CreatePath(oldPath.GetDirectory(), oldPath.GetName(false) + TString(buffer) + oldPath.GetExtension());
		} 
		while (IsFileExists(uniquePath.c_str()));

        return uniquePath;
    }
开发者ID:flying19880517,项目名称:AntiDupl,代码行数:18,代码来源:adFileUtils.cpp

示例10: MKDEV

TError TTask::ChildMountDev() {
    struct {
        const std::string path;
        unsigned int mode;
        unsigned int dev;
    } node[] = {
        { "/dev/null",    0666 | S_IFCHR, MKDEV(1, 3) },
        { "/dev/zero",    0666 | S_IFCHR, MKDEV(1, 5) },
        { "/dev/full",    0666 | S_IFCHR, MKDEV(1, 7) },
        { "/dev/random",  0666 | S_IFCHR, MKDEV(1, 8) },
        { "/dev/urandom", 0666 | S_IFCHR, MKDEV(1, 9) },
    };

    TMount dev("tmpfs", Env->Root + "/dev", "tmpfs", { "mode=755", "size=32m" });
    TError error = dev.MountDir(MS_NOSUID | MS_STRICTATIME);
    if (error)
        return error;

    TMount devpts("devpts", Env->Root + "/dev/pts", "devpts",
                  { "newinstance", "ptmxmode=0666", "mode=620" ,"gid=5" });
    error = devpts.MountDir(MS_NOSUID | MS_NOEXEC);
    if (error)
        return error;

    for (size_t i = 0; i < sizeof(node) / sizeof(node[0]); i++) {
        error = ChildCreateNode(Env->Root + node[i].path,
                           node[i].mode, node[i].dev);
        if (error)
            return error;
    }

    TPath ptmx = Env->Root + "/dev/ptmx";
    if (symlink("pts/ptmx", ptmx.ToString().c_str()) < 0)
        return TError(EError::Unknown, errno, "symlink(/dev/pts/ptmx)");

    TPath fd = Env->Root + "/dev/fd";
    if (symlink("/proc/self/fd", fd.ToString().c_str()) < 0)
        return TError(EError::Unknown, errno, "symlink(/dev/fd)");

    TFile f(Env->Root + "/dev/console", 0755);
    (void)f.Touch();

    return TError::Success();
}
开发者ID:presto53,项目名称:porto,代码行数:44,代码来源:task.cpp

示例11: Snapshot

TError TMount::Snapshot(std::vector<std::shared_ptr<TMount>> &result, const TPath mounts) {
    FILE* f = setmntent(mounts.c_str(), "r");
    if (!f)
        return TError(EError::Unknown, errno, "setmntent(" + mounts.ToString() + ")");

    struct mntent* m, mntbuf;
    TScopedMem buf(4096);
    while ((m = getmntent_r(f, &mntbuf, (char *)buf.GetData(), buf.GetSize()))) {
        vector<string> flags;
        TError error = SplitString(m->mnt_opts, ',', flags);
        if (error) {
            endmntent(f);
            return error;
        }
        result.push_back(std::make_shared<TMount>(m->mnt_fsname, m->mnt_dir, m->mnt_type, flags));
    }
    endmntent(f);
    return TError::Success();
}
开发者ID:presto53,项目名称:porto,代码行数:19,代码来源:mount.cpp

示例12: new

// ---------------------------------------------------------------------------
// CAknMemorySelectionModelMultiDrive::ReadUserDefinedDataL
// ---------------------------------------------------------------------------
//
void CAknMemorySelectionModelMultiDrive::ReadUserDefinedDataL(
    TResourceReader& aReader, TInt aLocations )
    {
    if ( aLocations <= 0)
        {
        return;
        }
    
    iDefDriveArray = new ( ELeave ) CDesCArrayFlat( aLocations );
    iDefDefaultFolderArray = new ( ELeave ) CDesCArrayFlat( aLocations );
    for ( TInt i = 0; i < aLocations; i++ )
        {
        // read the location, save path and default folder in array
        TPath temp;
        temp.Copy( aReader.ReadTPtrC() );
        iDefDriveArray->AppendL( temp );
        temp.Copy( aReader.ReadTPtrC() );
        iDefDefaultFolderArray->AppendL( temp );
        }
    }
开发者ID:cdaffara,项目名称:symbiandump-mw1,代码行数:24,代码来源:caknmemoryselectionmodelmultidrive.cpp

示例13: ChildOpenStdFile

TError TTask::ChildOpenStdFile(const TPath &path, int expected) {
    int ret = open(path.ToString().c_str(), O_CREAT | O_WRONLY | O_APPEND, 0660);
    if (ret < 0)
        return TError(EError::InvalidValue, errno,
                      "open(" + path.ToString() + ") -> " +
                      std::to_string(expected));

    if (ret != expected)
        return TError(EError::Unknown, EINVAL,
                      "open(" + path.ToString() + ") -> " +
                      std::to_string(expected) + ": unexpected fd " +
                      std::to_string(ret));

    ret = fchown(ret, Env->Cred.Uid, Env->Cred.Gid);
    if (ret < 0)
        return TError(EError::Unknown, errno,
                      "fchown(" + path.ToString() + ") -> " +
                      std::to_string(expected));

    return TError::Success();
}
开发者ID:presto53,项目名称:porto,代码行数:21,代码来源:task.cpp

示例14: TError

TError TMount::Find(TPath path, const TPath mounts) {

    path = path.NormalPath();
    auto device = path.GetDev();
    if (!device)
        return TError(EError::Unknown, "device not found: " + path.ToString() + ")");

    FILE* f = setmntent(mounts.c_str(), "r");
    if (!f)
        return TError(EError::Unknown, errno, "setmntent(" + mounts.ToString() + ")");

    struct mntent* m, mntbuf;
    TScopedMem buf(4096);
    TError error(EError::Unknown, "mountpoint not found: " + path.ToString() + ")");

    while ((m = getmntent_r(f, &mntbuf, (char *)buf.GetData(), buf.GetSize()))) {

        TPath source(m->mnt_fsname);
        TPath target(m->mnt_dir);

        if (target.InnerPath(path).IsEmpty() ||
                source.GetBlockDev() != device)
            continue;

        Source = source;
        Target = target;
        Type = m->mnt_type;
        Data.clear();
        error = SplitString(m->mnt_opts, ',', Data);
        break;
    }
    endmntent(f);

    return error;
}
开发者ID:presto53,项目名称:porto,代码行数:35,代码来源:mount.cpp

示例15: ChildBindDirectores

TError TTask::ChildBindDirectores() {
    for (auto &bindMap : Env->BindMap) {
        TPath dest;

        if (bindMap.Dest.IsAbsolute())
            dest = Env->Root / bindMap.Dest;
        else
            dest = Env->Root / Env->Cwd / bindMap.Dest;

        if (!StringStartsWith(dest.RealPath().ToString(), Env->Root.ToString()))
            return TError(EError::InvalidValue, "Container bind mount "
                          + bindMap.Source.ToString() + " resolves to root "
                          + dest.RealPath().ToString()
                          + " (" + Env->Root.ToString() + ")");

        TMount mnt(bindMap.Source, dest, "none", {});

        TError error;
        if (bindMap.Source.GetType() == EFileType::Directory)
            error = mnt.BindDir(bindMap.Rdonly);
        else
            error = mnt.BindFile(bindMap.Rdonly);
        if (error)
            return error;

        // drop nosuid,noexec,nodev from volumes
        if (Env->NewMountNs) {
            error = TMount::Remount(dest, MS_REMOUNT | MS_BIND |
                                    (bindMap.Rdonly ? MS_RDONLY : 0));
            if (error)
                return error;
        }
    }

    return TError::Success();
}
开发者ID:presto53,项目名称:porto,代码行数:36,代码来源:task.cpp


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