本文整理汇总了C++中TPath类的典型用法代码示例。如果您正苦于以下问题:C++ TPath类的具体用法?C++ TPath怎么用?C++ TPath使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TPath类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: BootstrapCommand
void BootstrapCommand(const std::string &cmd, const TPath &path, bool remove) {
if (remove)
(void)path.RemoveAll();
vector<string> lines;
ExpectSuccess(Popen("ldd " + cmd, lines));
for (auto &line : lines) {
vector<string> tokens;
TError error = SplitString(line, ' ', tokens);
if (error)
throw error.GetMsg();
TPath from;
string name;
if (tokens.size() == 2) {
from = StringTrim(tokens[0]);
TPath p(tokens[0]);
name = p.BaseName();
} else if (tokens.size() == 4) {
if (tokens[2] == "")
continue;
from = StringTrim(tokens[2]);
name = StringTrim(tokens[0]);
} else {
continue;
}
TPath dest = path / from.DirName();
if (!dest.Exists()) {
error = dest.MkdirAll(0755);
if (error)
throw error.GetMsg();
}
Expect(system(("cp " + from.ToString() + " " + dest.ToString() + "/" + name).c_str()) == 0);
}
Expect(system(("cp " + cmd + " " + path.ToString()).c_str()) == 0);
}
开发者ID:noxiouz,项目名称:porto,代码行数:40,代码来源:test.cpp
示例17: GenerateDestPath
/**
Copy or resize if need be a source image to the internal folder
@return A file path of the new destination of the rescaled image
@param aSourceFile Source image path to be resized
@param aItem Contact item to help naming the new image
*/
TPath CImageRescaler::ResizeAndCopyImage(const TDesC& aSourceFile, const CContactItem& aItem)
{
TPtrC guid = const_cast<CContactItem&>(aItem).Guid();
// Remove the old file. An empty guid means that this contact is new and
// does not have any image associated with it in the images dir
if (guid.Length())
{
TPath oldFile;
oldFile.Append(iImagesDirPath);
oldFile.Append(guid);
oldFile.Append(_L("*"));
// Remove previous file(s)
BaflUtils::DeleteFile(iFs, oldFile); // Error value not necessary
}
TPath destFile = GenerateDestPath(aSourceFile);
// Check the size of the image
if (IsImageTooLarge(aSourceFile))
{
// Resize image
TRAPD(err, ResizeImageL(aSourceFile, destFile));
if (err != KErrNone && err != KErrArgument)
{
// Copy original image to the images directory to ensure
// the contact keeps a copy of the image
if (BaflUtils::CopyFile(iFs, aSourceFile, destFile) != KErrNone)
{
destFile.Zero();
}
}
}
else
{
// Copy image to the images directory if the image is not to big
if (BaflUtils::CopyFile(iFs, aSourceFile, destFile) != KErrNone)
{
destFile.Zero();
}
}
return destFile;
}
开发者ID:,项目名称:,代码行数:53,代码来源:
示例18: GetDigitInFileName
// Ищет цифры в имени файла с конца.
__int64 GetDigitInFileName(const TPath &path, TString & nameWithoutDigit, size_t & leadingZeros)
{
TString name = path.GetName(false);
size_t length = name.length();
//Находим первый не числовой символ с конца
bool canRename;
size_t digitPos = length;
for (ptrdiff_t i = length - 1; i >= 0; digitPos = i, i-- )
{
if (!iswdigit(name[i])) //если не цифра выходим
break;
}
if (digitPos <= length - 1) //если цифра найдена
canRename = true;
else
canRename = false;
__int64 result = -1;
int numOfZero = 0;
if (canRename)
{
TString forParsing = name.substr(digitPos, length - digitPos);
result = _wtoi64(forParsing.c_str());
if (result == _I64_MAX) //слишком длинный
{
digitPos = 0;
result = -1;
}
leadingZeros = forParsing.length() - LengthOfLong(result);
}
if (digitPos > 0 && digitPos < length)
nameWithoutDigit = name.substr(0, digitPos);
else
nameWithoutDigit = TString();
return result;
}
开发者ID:flying19880517,项目名称:AntiDupl,代码行数:40,代码来源:adFileUtils.cpp
示例19: ChildRemountRootRo
TError TTask::ChildRemountRootRo() {
if (!Env->RootRdOnly || !Env->Loop.IsEmpty())
return TError::Success();
// remount everything except binds to ro
std::vector<std::shared_ptr<TMount>> snapshot;
TError error = TMount::Snapshot(snapshot);
if (error)
return error;
for (auto mnt : snapshot) {
TPath path = Env->Root.InnerPath(mnt->GetMountpoint());
if (path.IsEmpty())
continue;
bool skip = false;
for (auto dir : roproc) {
if (!path.InnerPath(dir).IsEmpty()) {
skip = true;
break;
}
}
if (skip)
continue;
for (auto &bindMap : Env->BindMap) {
TPath dest = bindMap.Dest;
if (dest.NormalPath() == path.NormalPath()) {
skip = true;
break;
}
}
if (skip)
continue;
L_ACT() << "Remount " << path << " ro" << std::endl;
error = TMount::Remount(mnt->GetMountpoint(),
MS_REMOUNT | MS_BIND | MS_RDONLY);
if (error)
return error;
}
return TError::Success();
}
开发者ID:presto53,项目名称:porto,代码行数:46,代码来源:task.cpp
示例20: SetupLoopDevice
TError SetupLoopDevice(TPath image, int &dev)
{
static std::mutex BigLoopLock;
int control_fd, image_fd, loop_nr, loop_fd;
struct loop_info64 info;
std::string loop;
int retry = 10;
TError error;
image_fd = open(image.c_str(), O_RDWR | O_CLOEXEC);
if (image_fd < 0) {
error = TError(EError::Unknown, errno, "open(" + image.ToString() + ")");
goto err_image;
}
control_fd = open("/dev/loop-control", O_RDWR | O_CLOEXEC);
if (control_fd < 0) {
error = TError(EError::Unknown, errno, "open(/dev/loop-control)");
goto err_control;
}
BigLoopLock.lock();
again:
loop_nr = ioctl(control_fd, LOOP_CTL_GET_FREE);
if (loop_nr < 0) {
error = TError(EError::Unknown, errno, "ioctl(LOOP_CTL_GET_FREE)");
goto err_get_free;
}
loop = "/dev/loop" + std::to_string(loop_nr);
loop_fd = open(loop.c_str(), O_RDWR | O_CLOEXEC);
if (loop_fd < 0) {
error = TError(EError::Unknown, errno, "open(" + loop + ")");
goto err_loop_open;
}
if (ioctl(loop_fd, LOOP_SET_FD, image_fd) < 0) {
error = TError(EError::Unknown, errno, "ioctl(LOOP_SET_FD)");
if (errno == EBUSY) {
if (!ioctl(loop_fd, LOOP_GET_STATUS64, &info) || errno == ENXIO) {
if (--retry > 0) {
close(loop_fd);
goto again;
}
}
}
goto err_set_fd;
}
memset(&info, 0, sizeof(info));
strncpy((char *)info.lo_file_name, image.c_str(), LO_NAME_SIZE);
if (ioctl(loop_fd, LOOP_SET_STATUS64, &info) < 0) {
error = TError(EError::Unknown, errno, "ioctl(LOOP_SET_STATUS64)");
ioctl(loop_fd, LOOP_CLR_FD, 0);
goto err_set_status;
}
dev = loop_nr;
error = TError::Success();
err_set_status:
err_set_fd:
close(loop_fd);
err_loop_open:
err_get_free:
BigLoopLock.unlock();
close(control_fd);
err_control:
close(image_fd);
err_image:
return error;
}
开发者ID:presto53,项目名称:porto,代码行数:73,代码来源:mount.cpp
注:本文中的TPath类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论