Пример #1
0
bool DirectoryFileSystem::RemoveFile(const std::string &filename) {
	std::string fullName = GetLocalPath(filename);
#ifdef _WIN32
	bool retValue = (::DeleteFileA(fullName.c_str()) == TRUE);
#else
	bool retValue = (0 == unlink(fullName.c_str()));
#endif

#if HOST_IS_CASE_SENSITIVE
	if (! retValue)
	{
		// May have failed due to case sensitivity, so try again
		fullName = filename;
		if ( ! FixPathCase(basePath,fullName, FPC_FILE_MUST_EXIST) )
			return false;  // or go on and attempt (for a better error code than just false?)
		fullName = GetLocalPath(fullName);

#ifdef _WIN32
		retValue = (::DeleteFileA(fullName.c_str()) == TRUE);
#else
		retValue = (0 == unlink(fullName.c_str()));
#endif
	}
#endif

	return retValue;
}
Пример #2
0
PSPFileInfo DirectoryFileSystem::GetFileInfo(std::string filename) {
	PSPFileInfo x;
	x.name = filename;

	std::string fullName = GetLocalPath(filename);
	if (! File::Exists(fullName)) {
#if HOST_IS_CASE_SENSITIVE
		if (! FixPathCase(basePath,filename, FPC_FILE_MUST_EXIST))
			return x;
		fullName = GetLocalPath(filename);

		if (! File::Exists(fullName))
			return x;
#else
		return x;
#endif
	}
	x.type = File::IsDirectory(fullName) ? FILETYPE_DIRECTORY : FILETYPE_NORMAL;
	x.exists = true;

	if (x.type != FILETYPE_DIRECTORY)
	{
		struct stat s;
		stat(fullName.c_str(), &s);

		x.size = File::GetSize(fullName);
		x.access = s.st_mode & 0x1FF;
		localtime_r((time_t*)&s.st_atime,&x.atime);
		localtime_r((time_t*)&s.st_ctime,&x.ctime);
		localtime_r((time_t*)&s.st_mtime,&x.mtime);
	}

	return x;
}
int DirectoryFileSystem::RenameFile(const std::string &from, const std::string &to) {
	std::string fullTo = to;

	// Rename ignores the path (even if specified) on to.
	size_t chop_at = to.find_last_of('/');
	if (chop_at != to.npos)
		fullTo = to.substr(chop_at + 1);

	// Now put it in the same directory as from.
	size_t dirname_end = from.find_last_of('/');
	if (dirname_end != from.npos)
		fullTo = from.substr(0, dirname_end + 1) + fullTo;

	// At this point, we should check if the paths match and give an already exists error.
	if (from == fullTo)
		return SCE_KERNEL_ERROR_ERRNO_FILE_ALREADY_EXISTS;

	std::string fullFrom = GetLocalPath(from);

#if HOST_IS_CASE_SENSITIVE
	// In case TO should overwrite a file with different case
	if ( ! FixPathCase(basePath,fullTo, FPC_PATH_MUST_EXIST) )
		return -1;  // or go on and attempt (for a better error code than just false?)
#endif

	fullTo = GetLocalPath(fullTo);
	const char * fullToC = fullTo.c_str();

#ifdef _WIN32_NO_MINGW
	bool retValue = (MoveFile(ConvertUTF8ToWString(fullFrom).c_str(), ConvertUTF8ToWString(fullToC).c_str()) == TRUE);
#else
	bool retValue = (0 == rename(fullFrom.c_str(), fullToC));
#endif

#if HOST_IS_CASE_SENSITIVE
	if (! retValue)
	{
		// May have failed due to case sensitivity on FROM, so try again
		fullFrom = from;
		if ( ! FixPathCase(basePath,fullFrom, FPC_FILE_MUST_EXIST) )
			return -1;  // or go on and attempt (for a better error code than just false?)
		fullFrom = GetLocalPath(fullFrom);

#ifdef _WIN32_NO_MINGW
		retValue = (MoveFile(fullFrom.c_str(), fullToC) == TRUE);
#else
		retValue = (0 == rename(fullFrom.c_str(), fullToC));
#endif
	}
#endif

	// TODO: Better error codes.
	return retValue ? 0 : (int)SCE_KERNEL_ERROR_ERRNO_FILE_ALREADY_EXISTS;
}
bool DirectoryFileSystem::MkDir(const std::string &dirname) {
#if HOST_IS_CASE_SENSITIVE
	// Must fix case BEFORE attempting, because MkDir would create
	// duplicate (different case) directories

	std::string fixedCase = dirname;
	if ( ! FixPathCase(basePath,fixedCase, FPC_PARTIAL_ALLOWED) )
		return false;

	return File::CreateFullPath(GetLocalPath(fixedCase));
#else
	return File::CreateFullPath(GetLocalPath(dirname));
#endif
}
NS_IMETHODIMP nsPop3IncomingServer::MarkMessages()
{
  nsresult rv;
  if (m_runningProtocol)
    rv = m_runningProtocol->MarkMessages(&m_uidlsToMark);
  else
  {
    nsCString hostName;
    nsCString userName;
    nsCOMPtr<nsIFile> localPath;

    GetLocalPath(getter_AddRefs(localPath));

    GetHostName(hostName);
    GetUsername(userName);
    // do it all in one fell swoop
    rv = nsPop3Protocol::MarkMsgForHost(hostName.get(), userName.get(), localPath, m_uidlsToMark);
  }
  uint32_t count = m_uidlsToMark.Length();
  for (uint32_t i = 0; i < count; i++)
  {
    Pop3UidlEntry *ue = m_uidlsToMark[i];
    PR_Free(ue->uidl);
    PR_Free(ue);
  }
  m_uidlsToMark.Clear();
  return rv;
}
Пример #6
0
	void SyncManager::handleDirectoriesToSyncUpdated (const QList<SyncerInfo>& infos)
	{
		QStringList paths;
		for (const auto& info : infos)
		{
			paths << info.LocalDirectory_;
			auto acc = AM_->GetAccountFromUniqueID (info.AccountId_);

			if (AccountID2Syncer_.contains (info.AccountId_))
			{
				auto syncer = AccountID2Syncer_ [info.AccountId_];
				if (syncer->GetLocalPath () == info.LocalDirectory_ &&
						syncer->GetRemotePath () == info.RemoteDirectory_)
					continue;
				else
				{

					//TODO update syncer
// 					syncer->stop ();
// 					AccountID2Syncer_.take (info.AccountId_)->deleteLater ();
				}
			}
			else
			{
				auto syncer = CreateSyncer (acc, info.LocalDirectory_, info.RemoteDirectory_);
				AccountID2Syncer_ [info.AccountId_] = syncer;
// 				syncer->start ();
			}
		}

		FilesWatcher_->updatePaths (paths);
	}
u32 VFSFileSystem::OpenFile(std::string filename, FileAccess access, const char *devicename) {
	if (access != FILEACCESS_READ) {
		ERROR_LOG(FILESYS, "VFSFileSystem only supports plain reading");
		return 0;
	}

	std::string fullName = GetLocalPath(filename);
	const char *fullNameC = fullName.c_str();
	DEBUG_LOG(FILESYS,"VFSFileSystem actually opening %s (%s)", fullNameC, filename.c_str());

	size_t size;
	u8 *data = VFSReadFile(fullNameC, &size);
	if (!data) {
		ERROR_LOG(FILESYS, "VFSFileSystem failed to open %s", filename.c_str());
		return 0;
	}

	OpenFileEntry entry;
	entry.fileData = data;
	entry.size = size;
	entry.seekPos = 0;
	u32 newHandle = hAlloc->GetNewHandle();
	entries[newHandle] = entry;
	return newHandle;
}
Пример #8
0
bool DirectoryFileSystem::MkDir(const std::string &dirname)
{
	std::string fullName = GetLocalPath(dirname);

	return File::CreateFullPath(fullName);

}
Пример #9
0
PSPFileInfo DirectoryFileSystem::GetFileInfo(std::string filename) 
{
	PSPFileInfo x; 
	x.name = filename;
	

	std::string fullName = GetLocalPath(filename);
	if (!File::Exists(fullName)) {
		return x;
	}
	x.type = File::IsDirectory(fullName) ? FILETYPE_NORMAL : FILETYPE_DIRECTORY;
	x.exists = true;

#ifdef _WIN32

	WIN32_FILE_ATTRIBUTE_DATA data;
	GetFileAttributesEx(fullName.c_str(), GetFileExInfoStandard, &data);

	x.size = data.nFileSizeLow | ((u64)data.nFileSizeHigh<<32);
#else
	x.size = File::GetSize(fullName);
	//TODO
#endif
	x.mtime = File::GetModifTime(fullName);

	return x;
}
	ERMsg CDirectoryManagerBase::Import(const std::string& filePath, const std::string& fileExt)const
	{
		ASSERT(!filePath.empty());
		ASSERT(m_bHaveLocalPath);
		ASSERT(!m_localPath.empty());

		ERMsg msg;

		if (!GetLocalPath().empty())
		{
			ASSERT(false);
			//std::string newName = GetLocalPath() + UtilWin::GetFileTitle( filePath ) + fileExt;

			//if( !DirExist(GetLocalPath()) )
			//{
			//	if( !CreateMultipleDir( GetLocalPath() ) )
			//	{
			//		msg.asgType(ERMsg::ERREUR);
			//		return msg;
			//	}
			//}

			//if( !::CopyFile( filePath, newName, true) )
			//      {
			//	msg = SYGetMessage( GetLastError() );
			//          std::string erreur;
			//          erreur.FormatMsg(IDS_CMN_FILENOTIMPORT, (LPCTSTR)filePath, (LPCTSTR)GetLocalPath() );
			//          msg.ajoute(erreur);
			//      }
		}


		return msg;
	}
status_t
ServerRepositoryDataUpdateProcess::ProcessLocalData()
{
	DepotMatchingRepositoryListener* itemListener =
		new DepotMatchingRepositoryListener(fModel, this);
	ObjectDeleter<DepotMatchingRepositoryListener>
		itemListenerDeleter(itemListener);

	BulkContainerDumpExportRepositoryJsonListener* listener =
		new BulkContainerDumpExportRepositoryJsonListener(itemListener);
	ObjectDeleter<BulkContainerDumpExportRepositoryJsonListener>
		listenerDeleter(listener);

	BPath localPath;
	status_t result = GetLocalPath(localPath);

	if (result != B_OK)
		return result;

	result = ParseJsonFromFileWithListener(listener, localPath);

	if (result != B_OK)
		return result;

	return listener->ErrorStatus();
}
Пример #12
0
bool DirectoryFileSystem::RmDir(const std::string &dirname)
{
	std::string fullName = GetLocalPath(dirname);
#ifdef _WIN32
	return RemoveDirectory(fullName.c_str()) == TRUE;
#else
  return 0 == rmdir(fullName.c_str());
#endif
}
Пример #13
0
//=============================================================================
// 函数名称:	设置当前工作目录
// 作者说明:	mushuai
// 修改时间:	2010-03-08
//=============================================================================
BOOL SetLocalCurrentDir()
{
	CString path=GetLocalPath();
	path+='\\';
	DWORD dwret=SetCurrentDirectory(path.GetBuffer(0));
	if (dwret==0)
		return FALSE;
	return TRUE;
}
Пример #14
0
bool DirectoryFileSystem::RenameFile(const std::string &from, const std::string &to)
{
	std::string fullFrom = GetLocalPath(from);
	std::string fullTo = to;
	// TO filename may not include path. Intention is that it uses FROM's path
	if (to.find("/") != std::string::npos) {
		int offset = from.find_last_of("/");
		if (offset >= 0) {
			fullTo = from.substr(0, offset + 1) + to;
		}
	}
	fullTo = GetLocalPath(fullTo);
#ifdef _WIN32
	return MoveFile(fullFrom.c_str(), fullTo.c_str()) == TRUE;
#else
	return 0 == rename(fullFrom.c_str(), fullTo.c_str());
#endif
}
Пример #15
0
bool DirectoryFileSystem::DeleteFile(const std::string &filename)
{
	std::string fullName = GetLocalPath(filename);
#ifdef _WIN32
	return DeleteFile(fullName.c_str()) == TRUE;
#else
  return 0 == unlink(fullName.c_str());
#endif
}
Пример #16
0
PSPFileInfo DirectoryFileSystem::GetFileInfo(std::string filename) {
	PSPFileInfo x;
	x.name = filename;

	std::string fullName = GetLocalPath(filename);
	if (!File::Exists(fullName)) {
#if HOST_IS_CASE_SENSITIVE
		if (! FixPathCase(basePath,filename, FPC_FILE_MUST_EXIST))
			return x;
		fullName = GetLocalPath(filename);

		if (! File::Exists(fullName))
			return x;
#else
		return x;
#endif
	}
	x.type = File::IsDirectory(fullName) ? FILETYPE_DIRECTORY : FILETYPE_NORMAL;
	x.exists = true;

	if (x.type != FILETYPE_DIRECTORY) {
		File::FileDetails details;
		if (!File::GetFileDetails(fullName, &details)) {
			ERROR_LOG(FILESYS, "DirectoryFileSystem::GetFileInfo: GetFileDetails failed: %s", fullName.c_str());
			x.size = 0;
			x.access = 0;
			memset(&x.atime, 0, sizeof(x.atime));
			memset(&x.ctime, 0, sizeof(x.ctime));
			memset(&x.mtime, 0, sizeof(x.mtime));
		} else {
			x.size = details.size;
			x.access = details.access;
			time_t atime = details.atime;
			time_t ctime = details.ctime;
			time_t mtime = details.mtime;

			localtime_r((time_t*)&atime, &x.atime);
			localtime_r((time_t*)&ctime, &x.ctime);
			localtime_r((time_t*)&mtime, &x.mtime);
		}
	}

	return x;
}
Пример #17
0
int VirtualDiscFileSystem::getFileListIndex(std::string &fileName)
{
	std::string normalized;
	if (fileName.length() >= 1 && fileName[0] == '/') {
		normalized = fileName.substr(1);
	} else {
		normalized = fileName;
	}

	for (size_t i = 0; i < fileList.size(); i++)
	{
		if (fileList[i].fileName == normalized)
			return (int)i;
	}

	// unknown file - add it
	std::string fullName = GetLocalPath(fileName);
	if (! File::Exists(fullName)) {
#if HOST_IS_CASE_SENSITIVE
		if (! FixPathCase(basePath,fileName, FPC_FILE_MUST_EXIST))
			return -1;
		fullName = GetLocalPath(fileName);

		if (! File::Exists(fullName))
			return -1;
#else
		return -1;
#endif
	}

	FileType type = File::IsDirectory(fullName) ? FILETYPE_DIRECTORY : FILETYPE_NORMAL;
	if (type == FILETYPE_DIRECTORY)
		return -1;

	FileListEntry entry = {""};
	entry.fileName = normalized;
	entry.totalSize = File::GetFileSize(fullName);
	entry.firstBlock = currentBlockIndex;
	currentBlockIndex += (entry.totalSize+2047)/2048;

	fileList.push_back(entry);

	return (int)fileList.size()-1;
}
Пример #18
0
bool DirectoryFileSystem::MkDir(const std::string &dirname)
{
	std::string fullName = GetLocalPath(dirname);
#ifdef _WIN32
	return CreateDirectory(fullName.c_str(), NULL) == TRUE;
#else
  mkdir(fullName.c_str(), 0777);
  return true;
#endif
}
Пример #19
0
/*----------------------------------------------------------------------
  Save an opened document to a specified path in order to open.
  The parameter doc is the original doc to be saved
  The parameter newdoc is the new document
  The parameter newpath is the newdoc URI
  Return the saved localFile (to be freed) or NULL
  ----------------------------------------------------------------------*/
char *SaveDocumentToNewDoc(Document doc, Document newdoc, char* newpath)
{
  ElementType   elType;
  Element       root;
  char         *localFile = NULL, *s;
  ThotBool      res = FALSE;

  localFile = GetLocalPath (newdoc, newpath);

  // apply link changes to the template
    TtaOpenUndoSequence (doc, NULL, NULL, 0, 0);
  SetRelativeURLs (doc, newpath, NULL, FALSE, FALSE, FALSE, FALSE);
  // prepare the new document view
  TtaExtractName (newpath, DirectoryName, DocumentName);

  root = TtaGetRootElement(doc);
  elType = TtaGetElementType (root);
  // get the target document type
  s = TtaGetSSchemaName (elType.ElSSchema);
  if (!IsNotHTMLorHTML5 (s))
    {

	  if (TtaGetDocumentProfile(doc) == L_HTML5 || TtaGetDocumentProfile(doc) == L_HTML5_LEGACY)
		 res = TtaExportDocumentWithNewLineNumbers (doc, localFile, "HTML5TX", FALSE);
	  else
	  {
		  /* docType = docHTML; */
		  if (TtaGetDocumentProfile(doc) == L_Xhtml11 ||
			  TtaGetDocumentProfile(doc) == L_Basic)
			res = TtaExportDocumentWithNewLineNumbers (doc, localFile, "HTMLT11", FALSE);
		  else
			res = TtaExportDocumentWithNewLineNumbers (doc, localFile, "HTMLTX", FALSE);
	  }
    }
  else if (strcmp (s, "SVG") == 0)
    /* docType = docSVG; */
    res = TtaExportDocumentWithNewLineNumbers (doc, localFile, "SVGT", FALSE);
  else if (strcmp (s, "MathML") == 0)
    /* docType = docMath; */
    res = TtaExportDocumentWithNewLineNumbers (doc, localFile, "MathMLT", FALSE);
  else
    /* docType = docXml; */
    res = TtaExportDocumentWithNewLineNumbers (doc, localFile, NULL, FALSE);

  // restore the previous state of the template
  TtaCloseUndoSequence (doc);
  TtaUndoNoRedo (doc);
  if (res)
    return localFile;
  else
    {
      TtaFreeMemory (localFile);
      return NULL;
    }
}
Пример #20
0
int CUpdator::Log(LPCTSTR msg)
{
	static SampleTxtLogger slog;
	if (!slog.m_state)
	{
		CString spath = GetLocalPath()+_T("\\log.txt");
		slog.Initialize(spath);
	}
	slog.Log(0,_T("%s"),msg);
	return 0;
}
Пример #21
0
bool DirectoryFileSystem::RenameFile(const std::string &from, const std::string &to) {
	std::string fullTo = to;

	// Rename only work for filename in current directory

	std::string fullFrom = GetLocalPath(from);

#if HOST_IS_CASE_SENSITIVE
	// In case TO should overwrite a file with different case
	if ( ! FixPathCase(fullTo, FPC_PATH_MUST_EXIST) )
		return false;  // or go on and attempt (for a better error code than just false?)
#endif

	fullTo = GetLocalPath(fullTo);
	const char * fullToC = fullTo.c_str();

#ifdef _WIN32
	bool retValue = (MoveFile(fullFrom.c_str(), fullToC) == TRUE);
#else
	bool retValue = (0 == rename(fullFrom.c_str(), fullToC));
#endif

#if HOST_IS_CASE_SENSITIVE
	if (! retValue)
	{
		// May have failed due to case sensitivity on FROM, so try again
		fullFrom = from;
		if ( ! FixPathCase(fullFrom, FPC_FILE_MUST_EXIST) )
			return false;  // or go on and attempt (for a better error code than just false?)
		fullFrom = GetLocalPath(fullFrom);

#ifdef _WIN32
		retValue = (MoveFile(fullFrom.c_str(), fullToC) == TRUE);
#else
		retValue = (0 == rename(fullFrom.c_str(), fullToC));
#endif
	}
#endif

	return retValue;
}
Пример #22
0
u32 DirectoryFileSystem::OpenFile(std::string filename, FileAccess access)
{
	std::string fullName = GetLocalPath(filename);
	INFO_LOG(HLE,"Actually opening %s",fullName.c_str());

	OpenFileEntry entry;

#ifdef _WIN32
	// Convert parameters to Windows permissions and access
	DWORD desired = 0;
	DWORD sharemode = 0;
	DWORD openmode = 0;
	if (access & FILEACCESS_READ)
	{
		desired   |= GENERIC_READ;
		sharemode |= FILE_SHARE_READ;
	}
	if (access & FILEACCESS_WRITE)
	{
		desired   |= GENERIC_WRITE;
		sharemode |= FILE_SHARE_WRITE;
	}
	if (access & FILEACCESS_CREATE)
	{
		openmode = OPEN_ALWAYS;
	}
	else
		openmode = OPEN_EXISTING;

	//Let's do it!
	entry.hFile = CreateFile(fullName.c_str(), desired, sharemode, 0, openmode, 0, 0);
	bool success = entry.hFile != INVALID_HANDLE_VALUE;
#else
  entry.hFile = fopen(fullName.c_str(), access & FILEACCESS_WRITE ? "wb" : "rb");
  bool success = entry.hFile != 0;
#endif

	if (!success)
	{
#ifdef _WIN32
    ERROR_LOG(HLE, "DirectoryFileSystem::OpenFile: FAILED, %i", GetLastError());
#endif
		//wwwwaaaaahh!!
		return 0;
	}
	else
	{
		u32 newHandle = hAlloc->GetNewHandle();
		entries[newHandle] = entry;

		return newHandle;
	}
}
	//this default implementation import all file in the same directory
	//that have the same file title
	ERMsg CDirectoryManager::Import(const std::string& filePath)const
	{
		ERMsg msg;

		if (!GetLocalPath().empty())
		{
			if (!DirectoryExists(GetLocalPath()))
			{
				msg = CreateMultipleDir(GetLocalPath());
			}

			if (msg)
			{
				std::string newFilePath = GetLocalPath() + GetFileName(filePath);
				msg = CopyFile(filePath, newFilePath);

				/*std::string strSrh = filePath;
				UtilWin::SetFileExtension(strSrh, ".*");

				StringVector filePathList;
				UtilWin::GetFilesList(filePathList, strSrh, true);
				for(int i=0; i<filePathListsize(); i++)
				{
				std::string newFilePath = GetLocalPath() + UtilWin::GetFileName( filePathList[i] );

				if( !::CopyFile( filePathList[i], newFilePath, true) )
				{
				msg = SYGetMessage( GetLastError() );
				std::string erreur;
				erreur.FormatMsg(IDS_CMN_FILENOTIMPORT, (LPCTSTR)filePath, (LPCTSTR)GetLocalPath() );
				msg.ajoute(erreur);
				}
				}*/
			}


		}
		return msg;

	}
Пример #24
0
PSPFileInfo DirectoryFileSystem::GetFileInfo(std::string filename) {
	PSPFileInfo x;
	x.name = filename;

	std::string fullName = GetLocalPath(filename);
	if (! File::Exists(fullName)) {
#if HOST_IS_CASE_SENSITIVE
		if (! FixPathCase(filename, FPC_FILE_MUST_EXIST))
			return x;
		fullName = GetLocalPath(filename);

		if (! File::Exists(fullName))
			return x;
#else
		return x;
#endif
	}
	x.type = File::IsDirectory(fullName) ? FILETYPE_DIRECTORY : FILETYPE_NORMAL;
	x.exists = true;

	if (x.type != FILETYPE_DIRECTORY)
	{
		struct stat s;
		stat(fullName.c_str(), &s);
#ifdef _WIN32
		WIN32_FILE_ATTRIBUTE_DATA data;
		GetFileAttributesEx(fullName.c_str(), GetFileExInfoStandard, &data);

		x.size = data.nFileSizeLow | ((u64)data.nFileSizeHigh<<32);
#else
		x.size = s.st_size;
#endif
		x.access = s.st_mode & 0x1FF;
		localtime_r((time_t*)&s.st_atime,&x.atime);
		localtime_r((time_t*)&s.st_ctime,&x.ctime);
		localtime_r((time_t*)&s.st_mtime,&x.mtime);
	}

	return x;
}
Пример #25
0
void CFolderItem::SaveItem(pugi::xml_node& element) const
{
    auto file = element.append_child("Folder");

    if (Download()) {
        AddTextElement(file, "LocalFile", GetLocalPath().GetPath() + GetLocalFile());
    }
    else {
        AddTextElement(file, "RemoteFile", GetRemoteFile());
        AddTextElement(file, "RemotePath", m_remotePath.GetSafePath());
    }
    AddTextElementUtf8(file, "Download", Download() ? "1" : "0");
}
Пример #26
0
nsresult nsRssIncomingServer::FillInDataSourcePath(const nsAString& aDataSourceName, nsILocalFile ** aLocation)
{
  nsresult rv;
  // start by gettting the local path for this server
  nsCOMPtr<nsILocalFile> localFile;
  rv = GetLocalPath(getter_AddRefs(localFile));
  NS_ENSURE_SUCCESS(rv, rv);

  // now append the name of the subscriptions data source
  rv = localFile->Append(aDataSourceName);
  NS_IF_ADDREF(*aLocation = localFile);
  return rv;
}
bool DirectoryFileSystem::RmDir(const std::string &dirname) {
	std::string fullName = GetLocalPath(dirname);

#if HOST_IS_CASE_SENSITIVE
	// Maybe we're lucky?
	if (File::DeleteDirRecursively(fullName))
		return true;

	// Nope, fix case and try again
	fullName = dirname;
	if ( ! FixPathCase(basePath,fullName, FPC_FILE_MUST_EXIST) )
		return false;  // or go on and attempt (for a better error code than just false?)

	fullName = GetLocalPath(fullName);
#endif

/*#ifdef _WIN32
	return RemoveDirectory(fullName.c_str()) == TRUE;
#else
	return 0 == rmdir(fullName.c_str());
#endif*/
	return File::DeleteDirRecursively(fullName);
}
Пример #28
0
void CFolderItem::SaveItem(TiXmlElement* pElement) const
{
	TiXmlElement *file = new TiXmlElement("Folder");

	if (Download())
		AddTextElement(file, "LocalFile", GetLocalPath().GetPath() + GetLocalFile());
	else
	{
		AddTextElement(file, "RemoteFile", GetRemoteFile());
		AddTextElement(file, "RemotePath", m_remotePath.GetSafePath());
	}
	AddTextElementRaw(file, "Download", Download() ? "1" : "0");

	pElement->LinkEndChild(file);
}
Пример #29
0
void CUpdator::UpdateRestart()
{
	if(m_updatee)
	{
		//waiting updatee quit
		CString msg;
		msg.Format(_T("wait updatee quit:%d"),m_updatee);
		LOG((LPCTSTR)msg);

		if(::WaitForSingleObject(m_updatee,INFINITE) != WAIT_OBJECT_0)
		{
			//msg.Format(_T("wait updatee error"));
			//MessageBox(0,(LPCTSTR)msg,0,MB_OK);
		}
		CloseHandle(m_updatee);
		m_updatee =0;
		//re update
		Sleep(20);
		int  r = PreUpdate();
	}
	LOG(_T("re start updatee"));

	for (int i=0;i<m_services.size();i++)
	{
		CString service = GetLocalPath()+m_services[i].c_str();
		Execute(service,"/service");
	}
	Sleep(200);
	if(m_updatee_path.length())
	{
		Execute(GetLocalPath()+m_updatee_path.c_str(),"/service");
		Sleep(200);
		Execute(GetLocalPath()+m_updatee_path.c_str());
	}
	
}
Пример #30
0
u64 DirectoryFileSystem::FreeSpace(const std::string &path) {
#ifdef _WIN32
	const std::wstring w32path = ConvertUTF8ToWString(GetLocalPath(path));
	ULARGE_INTEGER free;
	if (GetDiskFreeSpaceExW(w32path.c_str(), &free, nullptr, nullptr))
		return free.QuadPart;
#elif defined(__SYMBIAN32__)
	QSystemStorageInfo storageInfo;
	return (u64)storageInfo.availableDiskSpace("E");
#else
	std::string localPath = GetLocalPath(path);
	struct statvfs diskstat;
	int res = statvfs(localPath.c_str(), &diskstat);

#if HOST_IS_CASE_SENSITIVE
	std::string fixedCase = path;
	if (res != 0 && FixPathCase(basePath, fixedCase, FPC_FILE_MUST_EXIST)) {
		// May have failed due to case sensitivity, try again.
		localPath = GetLocalPath(fixedCase);
		res = statvfs(localPath.c_str(), &diskstat);
	}
#endif

	if (res == 0) {
#ifndef ANDROID
		if (diskstat.f_flag & ST_RDONLY) {
			return 0;
		}
#endif
		return (u64)diskstat.f_bavail * (u64)diskstat.f_frsize;
	}
#endif

	// Just assume they're swimming in free disk space if we don't know otherwise.
	return std::numeric_limits<u64>::max();
}