コード例 #1
0
ファイル: MtpFolder.cpp プロジェクト: JasonFerrara/jmtpfs
void MtpFolder::Rename(MtpNode& newParent, const std::string& newName)
{
	if (newName.length() > MAX_MTP_NAME_LENGTH)
		throw MtpNameTooLong();

	MtpNodeMetadata md = m_cache.getItem(m_id, *this);

	uint32_t parentId = GetParentNodeId();
	if ((newParent.FolderId() == md.self.parentId) && (newParent.StorageId() == m_storageId))
	{
		// we can do a real rename
		m_device.RenameFile(m_id, newName);
	}
	else
	{
		// we have to do a copy and delete
		newParent.mkdir(newName);
		std::unique_ptr<MtpNode> destDir(newParent.getNode(FilesystemPath(newName.c_str())));
		std::vector<std::string> contents = readDirectory();
		for(std::vector<std::string>::iterator i = contents.begin(); i != contents.end(); i++)
		{
			std::unique_ptr<MtpNode> child(getNode(FilesystemPath(i->c_str())));
			child->Rename(*destDir, *i);
		}
		Remove();
	}
	m_cache.clearItem(newParent.Id());
	m_cache.clearItem(parentId);

}
コード例 #2
0
	string CoreUnix::GetDefaultMountPointPrefix () const
	{
		const char *envPrefix = getenv ("TRUECRYPT64_MOUNT_PREFIX");
		if (envPrefix && !string (envPrefix).empty())
			return envPrefix;

		if (FilesystemPath ("/media").IsDirectory())
			return "/media/truecrypt64";

		if (FilesystemPath ("/mnt").IsDirectory())
			return "/mnt/truecrypt64";

		return GetTempDirectory() + "/truecrypt64_mnt";
	}
コード例 #3
0
ファイル: CoreUnix.cpp プロジェクト: CSRedRat/CipherShed
	string CoreUnix::GetDefaultMountPointPrefix () const
	{
		const char *envPrefix = getenv ("CIPHERSHED_MOUNT_PREFIX");
		if (envPrefix && !string (envPrefix).empty())
			return envPrefix;
		
		if (FilesystemPath ("/media").IsDirectory())
			return "/media/ciphershed";
		
		if (FilesystemPath ("/mnt").IsDirectory())
			return "/mnt/ciphershed";
		
		return GetTempDirectory() + "/ciphershed_mnt";
	}
コード例 #4
0
	bool SelectDirectoryWizardPage::IsValid ()
	{
		if (!DirectoryTextCtrl->IsEmpty())
		{
			return FilesystemPath (DirectoryTextCtrl->GetValue().wc_str()).IsDirectory();
		}

		return false;
	}
コード例 #5
0
ファイル: FuseService.cpp プロジェクト: anjo0722/CipherShed
	void FuseService::Mount (shared_ptr <Volume> openVolume, VolumeSlotNumber slotNumber, const string &fuseMountPoint)
	{
		list <string> args;
		args.push_back (FuseService::GetDeviceType());
		args.push_back (fuseMountPoint);

#ifdef TC_MACOSX
		args.push_back ("-o");
		args.push_back ("noping_diskarb");
		args.push_back ("-o");
		args.push_back ("nobrowse");

		if (getuid() == 0 || geteuid() == 0)
#endif
		{
			args.push_back ("-o");
			args.push_back ("allow_other");
		}
		
		ExecFunctor execFunctor (openVolume, slotNumber);
		Process::Execute ("fuse", args, -1, &execFunctor);

		for (int t = 0; true; t++)
		{
			try
			{
				if (FilesystemPath (fuseMountPoint + FuseService::GetControlPath()).GetType() == FilesystemPathType::File)
					break;
			}
			catch (...)
			{
				if (t > 50)
					throw;

				Thread::Sleep (100);
			}
		}
	}
コード例 #6
0
ファイル: CoreFreeBSD.cpp プロジェクト: cocoon/VeraCrypt
	HostDeviceList CoreFreeBSD::GetHostDevices (bool pathListOnly) const
	{
		HostDeviceList devices;
#ifdef TC_MACOSX
		const string busType = "rdisk";
#else
		foreach (const string &busType, StringConverter::Split ("ad da"))
#endif
		{
			for (int devNumber = 0; devNumber < 64; devNumber++)
			{
				stringstream devPath;
				devPath << "/dev/" << busType << devNumber;

				if (FilesystemPath (devPath.str()).IsBlockDevice() || FilesystemPath (devPath.str()).IsCharacterDevice())
				{
					make_shared_auto (HostDevice, device);
					device->Path = devPath.str();
					if (!pathListOnly)
					{
						try
						{
							device->Size = GetDeviceSize (device->Path);
						}
						catch (...)
						{
							device->Size = 0;
						}
						device->MountPoint = GetDeviceMountPoint (device->Path);
						device->SystemNumber = 0;
					}
					devices.push_back (device);

					for (int partNumber = 1; partNumber < 32; partNumber++)
					{
#ifdef TC_MACOSX
						const string partLetter = "";
#else
						foreach (const string &partLetter, StringConverter::Split (",a,b,c,d,e,f,g,h", ",", true))
#endif
						{
							stringstream partPath;
							partPath << devPath.str() << "s" << partNumber << partLetter;

							if (FilesystemPath (partPath.str()).IsBlockDevice() || FilesystemPath (partPath.str()).IsCharacterDevice())
							{
								make_shared_auto (HostDevice, partition);
								partition->Path = partPath.str();
								if (!pathListOnly)
								{
									try 
									{	        
										partition->Size = GetDeviceSize (partition->Path);
									}
									catch (...)
									{
										partition->Size = 0;
									}
									partition->MountPoint = GetDeviceMountPoint (partition->Path);
									partition->SystemNumber = 0;
								}

								device->Partitions.push_back (partition);
							}
						}
					}
				}
			}
		}
コード例 #7
0
ファイル: CoreSolaris.cpp プロジェクト: idukas/VeraCrypt
	HostDeviceList CoreSolaris::GetHostDevices (bool pathListOnly) const
	{
		HostDeviceList devices;

		foreach_ref (const FilePath &devPath, Directory::GetFilePaths ("/dev/rdsk", false))
		{
			string drivePath = devPath;
			if (drivePath.rfind ("p0") == drivePath.size() - 2)
			{
				make_shared_auto (HostDevice, device);
				device->Path = drivePath;

				try
				{
					device->Size = GetDeviceSize (device->Path);
				}
				catch (...)
				{
					device->Size = 0;
				}
				
				if (device->Size == 0)
					continue;

				device->MountPoint = GetDeviceMountPoint (device->Path);
				device->SystemNumber = 0;

				devices.push_back (device);

				for (int partNumber = 1; partNumber <= 32; partNumber++)
				{
					stringstream partPath;
					partPath << drivePath.substr (0, drivePath.size() - 1) << partNumber;

					if (FilesystemPath (partPath.str()).IsBlockDevice() || FilesystemPath (partPath.str()).IsCharacterDevice())
					{
						make_shared_auto (HostDevice, partition);
						partition->Path = partPath.str();

						try 
						{	        
							partition->Size = GetDeviceSize (partition->Path);
						}
						catch (...)
						{
							partition->Size = 0;
						}

						if (partition->Size == 0)
							continue;

						partition->MountPoint = GetDeviceMountPoint (partition->Path);
						partition->SystemNumber = 0;

						device->Partitions.push_back (partition);
					}
				}
			}
		}

		return devices;
	}