Exemple #1
0
__inline
BOOL CFileBase::GetFileName(const SYSTEMTIME &Time,
							CString &strFileName)
{
	CString strName[2]; 
	if (m_strFileName.GetLength() != 0)
	{
		GetFileName(Time, 1, strName[0], strName[1]);
		if (PathMatchSpec(m_strFileName, strName[0] + strName[1]))
		{
			strFileName = m_strFileName;
			return TRUE;
		}
	}

	CFileSearcher Searcher;
	if (Searcher.Search(this, Time, strFileName))
		return TRUE;
	
	GetFileName(Time, 0, strName[0], strName[1]);
	if (CreateFolder(strName[0]))
	{
		strFileName = strName[0] + strName[1];
		return TRUE;
	}

	return FALSE;
}
Exemple #2
0
/**
 * @brief Creates parent folder for specified file.
 * @param pszFileName - file name.
 * @return true if operation was completed successfully.
 */
BOOL CreateParentFolder(PCTSTR pszFileName)
{
	TCHAR szFolderPath[MAX_PATH];
	_tcscpy_s(szFolderPath, countof(szFolderPath), pszFileName);
	PathRemoveFileSpec(szFolderPath);
	return CreateFolder(szFolderPath);
}
Exemple #3
0
static BOOL CreateFolder(LPCTSTR pszFolder)
{
	char *pszWork;

	pszWork = (char*)malloc(MAX_PATH);
	lstrcpy(pszWork, pszFolder);

	if (!PathFileExists(pszWork)) {
		if (PathIsRoot(pszWork)) {
			free(pszWork);
			return FALSE;
		}

		char *pszWork2;
		pszWork2 = (char *)malloc(MAX_PATH);
		lstrcpy(pszWork2, pszWork);
		PathAddBackslash(pszWork2);
		lstrcpy(pszWork2, "..");
		PathCanonicalize(pszWork, pszWork2);
		free(pszWork2);

		if (CreateFolder(pszWork)) {
			BOOL ret = CreateDirectory(pszFolder, NULL);
			free(pszWork);
			return ret;
		} else {
			free(pszWork);
			return FALSE;
		}
	}

	free(pszWork);

	return TRUE;
}
BOOL CreateFolder(LPCTSTR szFolder)
{
	if (!szFolder || !lstrlen(szFolder))
		return FALSE;

	DWORD dwAttrib = GetFileAttributes(szFolder);

	// already exists ?
	if (dwAttrib != 0xffffffff)
		return ((dwAttrib & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY);

	// recursively create from the top down
	TCHAR* szPath = _tcsdup(szFolder);
	TCHAR* p = _tcsrchr(szPath, '\\');

	if (p) 
	{
		// The parent is a dir, not a drive
		*p = '\0';
			
		// if can't create parent
		if (!CreateFolder(szPath))
		{
			free(szPath);
			return FALSE;
		}
		free(szPath);

		if (!::CreateDirectory(szFolder, NULL)) 
			return FALSE;
	}
	
	return TRUE;
}
Exemple #5
0
HRESULT CFileHelper::WriteText(LPCTSTR path, LPCTSTR text)
{
	BOOL exists = FALSE;

	HRESULT hr = Contains(path, exists);
	if(FAILED(hr)) return hr;

	if( !exists)
	{
		String folder ;
		if(SUCCEEDED( GetParentFolder(path, folder)))
		{
			hr = CreateFolder(folder.c_str());	
			if(FAILED(hr)) return hr;
		}
	}	

	FileOutputStream ofs;

	ofs.imbue(locale("chs"));

	ofs.open(path);

	if(!ofs.is_open()) return E_FAIL;

	ofs.clear();

	ofs.write(text, STRLEN(text)/* *sizeof(TCHAR)*/);

	ofs.close();

	return S_OK;
}
Exemple #6
0
HRESULT CFileHelper::WriteBytes(LPCTSTR path, int count,const BYTE * bytes)
{
	BOOL exists = FALSE;

	HRESULT hr = Contains(path, exists);
	if(FAILED(hr)) return hr;

	if( !exists)
	{
		String folder ;
		if(SUCCEEDED(GetParentFolder(path, folder)))
		{
			hr = CreateFolder(folder.c_str());
			if(FAILED(hr)) return hr;
		}
	}

	ofstream ofs;

	ofs.open(path);

	if(!ofs.is_open()) return E_FAIL;

	ofs.clear();

	if(bytes) 	
		ofs.write((const char *)bytes,(int)count);

	ofs.close();

	return S_OK;

}
Exemple #7
0
void unzip(void *GamePath)
{
	CUnzipper zip;
	UZ_FileInfo info;
	char file_path[MAX_PATH];
	int num_files, i;
	FILE *fp;

	strcpy(file_path, (char *)GamePath);
	strcat(file_path, "\\Uninstall.cfg");

	fp = fopen(file_path, "w");

	if (fp != NULL)
	{
		zip.OpenZip("IA.ehf");
		//zip.SetOutputFolder((char *)GamePath);
		CreateFolder((char *)GamePath);

		num_files = zip.GetFileCount();

		for (i=0; i<num_files; i++)
		{
			zip.GetFileInfo(i, info); 
			zip.UnzipFile(i, (char *)GamePath, TRUE);

			fprintf(fp, "%s\\%s\n", GamePath, info.szFileName);
		}
	
		zip.CloseZip();

		fcloseall();
	}
	else
	{
		KillTimer(hWnd, 1);
		
		MessageBox(hWnd, "Error installing!  Code 2", "Error", MB_ICONEXCLAMATION|MB_OK);

		SetDlgItemText(hWnd, IDC_STATUS, "Error");

		return;
	}

	KillTimer(hWnd, 1);
	SetDlgItemText(hWnd, IDC_STATUS, "Done");

	SetDlgItemText(hWnd, IDC_CONTINUE, "Finish");
	EnableWindow(GetDlgItem(hWnd, IDC_CANCEL), FALSE);
	IsInstalled = TRUE;

	MessageBox(hWnd, "Imperial Alliance Installed!", "Success", MB_OK);

	return;
}
Exemple #8
0
BOOL CUnzipper::SetOutputFolder(LPCTSTR szFolder)
{
	DWORD dwAttrib = GetFileAttributes(szFolder);

	if (dwAttrib != 0xffffffff && !(dwAttrib & FILE_ATTRIBUTE_DIRECTORY))
		return FALSE;

	wcscpy_s(m_szOutputFolder, MAX_PATH + 1, szFolder);

	return CreateFolder(szFolder);
}
Exemple #9
0
// mklink /D "C:\existingFolder\Link" "C:\Target"
// mklink /D "C:\existingFolder\Link\" "C:\Target\"
// The ending slash is optional. The parent directory of the link must exist.
bool BrainUtil::MakeLink(const CString& link, const CString& target, bool bIsDirectory/* = true*/)
{
    CString temLink = link;
    CString temTarget = target;

    // delete the last '\'
    WCHAR lastChar = temLink.GetAt(temLink.GetLength() - 1);
    if(lastChar == _T('\\'))
        temLink.Truncate(temLink.GetLength() - 1); 

    if(DoesFileorFolderExist(temLink))
    {
        // Delete the link
        // For links to directories: rmdir linkname
        // For links to files: del linkname
        CString tmpCmd;
        tmpCmd.Format(_T("rmdir \"%s\""), temLink.GetBuffer());
        RunSystemCommand(tmpCmd);

        if(DoesFileorFolderExist(temLink)) // If still exist it might be a file link
        {
            tmpCmd.Format(_T("del \"%s\""), temLink.GetBuffer());
            RunSystemCommand(tmpCmd);
        }

        if(DoesFileorFolderExist(temLink))// check again
        {
            DATA_ASSERT(false); 
            return false;
        }
    }
    else
    {
        CString folderFullName = GetParentFolderName(link);
        if(!DoesFileorFolderExist(folderFullName))
        {
            bool bRet = CreateFolder(folderFullName); // Create the parent directory tree.
            if(!bRet)
                return false;
        }
    }

    CString cmd;
    if(bIsDirectory)
        cmd.Format(_T("mklink /D \"%s\" \"%s\""), temLink.GetBuffer(), temTarget.GetBuffer());
    else
        cmd.Format(_T("mklink \"%s\" \"%s\""), temLink.GetBuffer(), temTarget.GetBuffer());

    int ret = _wsystem(cmd.GetBuffer());
    DATA_ASSERT(0 == ret);
    bool bSucc = DoesFileorFolderExist(link);
    return bSucc;
}
Exemple #10
0
/**
* SendFolder
*
* Description: Send a folder and its contents to the ftp server.
*
* Param: con - describes the connection details to send.
*        file - describes the file, path must end in /. name and dir (is dir) are used.
*        waitDialog - message target to send progress updates. May or may not be displayed.
*/
bool CFtpManager::SendFolder(CConnection * con, CFileContainer & file, CWaitDialog & waitDialog)
{
	CString localStorePath;
	GetLocalStorePath(con, localStorePath);

	// Check
	if(file.dir == false)
	{
		return false;
	}

	// Create remote directory
	int r = CreateFolder(con, file.path, file.name);
	if(r == false)
	{
		// Error
		return false;
	}

	// Read files and folders in directory.
	localStorePath = localStorePath + CString(file.path + file.name) + _T("\\");
	localStorePath.Replace('/', '\\');
	CString localStoreSearchPath = CString(localStorePath + CString(_T("*.*")));

	// Read contents of folder
	CFileFind finder; 
	BOOL bWorking = finder.FindFile(localStoreSearchPath);
	while (bWorking)
	{
		bWorking = finder.FindNextFile();
		if(finder.IsDirectory())
		{
			CFileContainer f;
			f.dir = 1;
			f.name = finder.GetFileName(); 
			f.path = CString(file.path + file.name + _T("/"));
			if(f.name.GetLength() > 0 && f.name.Compare(_T(".")) != 0 && f.name.Compare(_T("..")) != 0)
			{
				SendFolder(con, f, waitDialog);
			}
		} 
		else 
		{
			CFileContainer f;
			f.dir = 0;
			f.name = finder.GetFileName(); 
			f.path = CString(file.path + file.name + _T("/"));
			SendFile(con, f, waitDialog);
		}
	}
	finder.Close();
	return true;
}
CString	CChordEaseApp::MakeDataFolderPath(LPCTSTR FileName, bool DefaultToAppFolder)
{
	CPathStr	path(GetDataFolderPath());
	if (!PathFileExists(path))
		CreateFolder(path);
	path.Append(FileName);
	if (DefaultToAppFolder && !PathFileExists(path)) {
		path = GetAppFolder();	// default to app folder
		path.Append(FileName);
	}
	return(path);
}
void CopyFolder(const KString&	SrcFolderName,
				const KString&	DstFolderName,
				TFileFilter*	pFilter,
				void*			pFilterParam,
				bool			bExceptionOnFail)
{
	// Getting complete folder names
	const KString SrcName = SlashedFolderName(SrcFolderName);
	const KString DstName = SlashedFolderName(DstFolderName);
	
	// Creating destination folder
	TEST_BLOCK_BEGIN
	{
		CreateFolder(DstName);
	}
	TEST_BLOCK_EXCEPTION_HANDLER
	{
		if(bExceptionOnFail)
			throw 1;

		return;
	}
	TEST_BLOCK_END

	// Copying
	KStrings::TConstIterator Iter;
	
	// Copying folders
	KStrings Folders;
	EnlistFolders(SrcName + TEXT("*.*"), Folders, false);	

	for(Iter = Folders.GetFirst() ; Iter.IsValid() ; ++Iter)
	{
		if(pFilter == NULL || pFilter(SrcName + *Iter, false, pFilterParam))
		{
			TEST_BLOCK_BEGIN
			{
				CopyFolder(	SrcName + *Iter,
							DstName + *Iter,
							pFilter,
							pFilterParam,
							bExceptionOnFail);
			}
			TEST_BLOCK_EXCEPTION_HANDLER
			{
				if(bExceptionOnFail)
					throw 1;
			}
			TEST_BLOCK_END
		}
	}
Exemple #13
0
void CFileManager::OnReceive(LPBYTE lpBuffer, UINT nSize)
{
	switch (lpBuffer[0])
	{
	case COMMAND_LIST_FILES:// 获取文件列表
		SendFilesList((char *)lpBuffer + 1);
		break;
	case COMMAND_DELETE_FILE:// 删除文件
		DeleteFile((char *)lpBuffer + 1);
		SendToken(TOKEN_DELETE_FINISH);
		break;
	case COMMAND_DELETE_DIRECTORY:// 删除文件
		////printf("删除目录 %s\n", (char *)(bPacket + 1));
		DeleteDirectory((char *)lpBuffer + 1);
		SendToken(TOKEN_DELETE_FINISH);
		break;
	case COMMAND_DOWN_FILES: // 上传文件
		UploadToRemote(lpBuffer + 1);
		break;
	case COMMAND_CONTINUE: // 上传文件
		SendFileData(lpBuffer + 1);
		break;
	case COMMAND_CREATE_FOLDER:
		CreateFolder(lpBuffer + 1);
		break;
	case COMMAND_RENAME_FILE:
		Rename(lpBuffer + 1);
		break;
	case COMMAND_STOP:
		StopTransfer();
		break;
	case COMMAND_SET_TRANSFER_MODE:
		SetTransferMode(lpBuffer + 1);
		break;
	case COMMAND_FILE_SIZE:
		CreateLocalRecvFile(lpBuffer + 1);
		break;
	case COMMAND_FILE_DATA:
		WriteLocalRecvFile(lpBuffer + 1, nSize -1);
		break;
	case COMMAND_OPEN_FILE_SHOW:
		OpenFile((char *)lpBuffer + 1, SW_SHOW);
		break;
	case COMMAND_OPEN_FILE_HIDE:
		OpenFile((char *)lpBuffer + 1, SW_HIDE);
		break;
	default:
		break;
	}
}
Exemple #14
0
bool cFile::CreateFolderRecursive(const AString & a_FolderPath)
{
	// Special case: Fail if the path is empty
	if (a_FolderPath.empty())
	{
		return false;
	}

	// Go through each path element and create the folder:
	auto len = a_FolderPath.length();
	auto PathSep = GetPathSeparator()[0];
	for (decltype(len) i = 0; i < len; i++)
	{
		if (a_FolderPath[i] == PathSep)
		{
			CreateFolder(a_FolderPath.substr(0, i));
		}
	}
	CreateFolder(a_FolderPath);

	// Check the result by querying whether the final path exists:
	return IsFolder(a_FolderPath);
}
Exemple #15
0
BOOL CFolder::OnInitDialog() 
{
	CDialog::OnInitDialog();

	HTREEITEM	hPar;
	CString		csTitle;
	DWORD       dwLen;
	DWORD		i;
	int			nType;
	WCHAR		*p;
	WCHAR		szLetter[4];
	WCHAR		szDrivesLetter[MAX_PATH];
	CBitmap     Bitmap;
	
	if (m_bShowFile)
	{
		csTitle.LoadString(IDS_SELECT_FILE_OR_DIR);
		SetWindowText(csTitle);
	}
	Bitmap.LoadBitmap(IDB_TREE);
	m_ImageList.Create(16,16,ILC_COLOR16,0,10);
	m_ImageList.Add(&Bitmap, RGB(0,0,0));
	m_Tree.SetImageList(&m_ImageList, TVSIL_NORMAL);

	dwLen = GetLogicalDriveStrings(0,NULL);
	::GetLogicalDriveStrings(dwLen,szDrivesLetter);
	_wcsupr( szDrivesLetter );
	p = szDrivesLetter;

	dwLen = dwLen/4;
	for(i = 0;i<dwLen;i++)
	{
		wcscpy(szLetter,p);
		//szLetter[2] = 0;
		nType = GetLetterType(szLetter);
		szLetter[2] = 0;
		if (nType < 7)
		{
			hPar = m_Tree.InsertItem(szLetter, nType, nType);
			m_Tree.SetItemData(hPar, 1);
			CreateFolder(szLetter, &m_Tree, hPar);
			m_Tree.SortChildren(hPar);
		}
		p += 4;
	}

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
BOOL CTxtFile::BakFile(CString strPath, CString strBakDir)
{
	int nYear, nMonth, nDay;
	GetCrtDate(nYear, nMonth, nDay);

	CString strYearMonth;
	strYearMonth.Format(_T("%d\\%d"), nYear, nMonth);

	CreateFolder(strBakDir+_T("\\")+strYearMonth);

	CString strSN;
	GetSN(strSN, strPath);

	return MoveFile(strPath, strBakDir+_T("\\")+strYearMonth+_T("\\")+strSN+_T(".tmp"));
}
Exemple #17
0
void CFolder::OnItemexpandingTree(NMHDR* pNMHDR, LRESULT* pResult) 
{
	NM_TREEVIEW* pView = (NM_TREEVIEW*)pNMHDR;
	CString	csDir;
	DWORD dwData;

	dwData = m_Tree.GetItemData(pView->itemNew.hItem);
	if(dwData == 0)//the first expand
	{
		m_Tree.SetItemData(pView->itemNew.hItem, 1);
		csDir = ConvertHTREEToPath(pView->itemNew.hItem, &m_Tree);
		CreateFolder(csDir, &m_Tree, pView->itemNew.hItem);
	}
	
	*pResult = 0;
}
Exemple #18
0
int CFSReg::Write(const CFSString &szPath, const BYTE *pData, INTPTR ipDataLen, DWORD dwDataType)
{
	if (ipDataLen<0) { // || (((UINTPTR)ipDataLen)>>(sizeof(DWORD)<<3))) {
		return -1;
	}
	HKEY hRoot; CFSString szFolder; CFSString szFile;
	if (Split(szPath, &hRoot, &szFolder, &szFile)!=0) {
		return -1;
	}
	HKEY hKey;
	if ((hKey=CreateFolder(hRoot, szFolder))==0) {
		return -1;
	}
	long lRes=RegSetValueEx(hKey, szFile, 0, dwDataType, pData, (DWORD)ipDataLen);
	RegCloseKey(hKey);
	return (lRes!=ERROR_SUCCESS);
}
Exemple #19
0
BOOL CFolder::CreateFolder(CString csDir, CTreeCtrl* pTree, HTREEITEM hPar, BOOL bIsSecond)
{
	WIN32_FIND_DATA dirData;
	HANDLE	hDir;
	CString	csPath = csDir + L"\\*.*";
	HTREEITEM	hSon;
	TVITEM	item;
	item.mask = TVIF_CHILDREN;
	item.cChildren = 1;

	
	hDir = FindFirstFile(csPath, &dirData);
	if(hDir == INVALID_HANDLE_VALUE)	return FALSE;
	do
	{
		if(wcscmp(dirData.cFileName,L".") && wcscmp(dirData.cFileName,L".."))
		{
			if(dirData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)//directory
			{
				if (bIsSecond)
				{
					FindClose(hDir);
					return TRUE;
				}
				hSon = pTree->InsertItem(dirData.cFileName, IMG_NORMAL, IMG_NORMAL + 1, hPar);
				
				csPath = csDir + L"\\";
				csPath += dirData.cFileName;
				if(CreateFolder(csPath, pTree, hSon, TRUE))
				{
					item.hItem = hSon;
					pTree->SetItem(&item);
					pTree->SetItemData(hSon, 0);
				}
			}
			else
			{
				if (!bIsSecond && m_bShowFile)
					hSon = pTree->InsertItem(dirData.cFileName, 10,10, hPar);
			}
		}
	}while(FindNextFile(hDir, &dirData) != 0);
	FindClose(hDir);

	return FALSE;
}
Exemple #20
0
void SNewFolderWindow::MessageReceived(BMessage* message)
{
	switch(message->what)
	{
		case MSG_NEWFOLDER_WINDOW_OK:
			CreateFolder();
			break;
	
		case MSG_NEWFOLDER_WINDOW_CANCEL:
			Quit();
			break;

		default:
			BWindow::MessageReceived(message);
	}

}
Exemple #21
0
void nsImportGenericMail::GetDefaultDestination(void)
{
  if (m_pDestFolder)
    return;
  if (!m_pInterface)
    return;

  nsIMsgFolder *  rootFolder;
  m_deleteDestFolder = false;
  m_createdFolder = false;
  if (CreateFolder(&rootFolder)) {
    m_pDestFolder = rootFolder;
    m_deleteDestFolder = true;
    m_createdFolder = true;
    return;
  }
  IMPORT_LOG0("*** GetDefaultDestination: Failed to create a default import destination folder.");
}
Exemple #22
0
BOOL CUnzipper::CreateFilePath(LPCTSTR szFilePath)
{
	TCHAR *szPath = _tcsdup(szFilePath);
	TCHAR *p = _tcsrchr(szPath,'\\');

	BOOL bRes = FALSE;

	if (p)
	{
		*p = '\0';

		bRes = CreateFolder(szPath);
	}

	free(szPath);

	return bRes;
}
Exemple #23
0
void CreateFolder(const char* path){	
	if(FolderExists(path)){
		return;
	}else{
		string s(path);
		string sep("\\");		
		string::iterator pos = std::find_end(s.begin(), s.end(), sep.begin(), sep.end());

		if (pos != s.end()){
			string s2(s.begin(), pos);
			//std::cout << s2 << std::endl;
			if (!FolderExists(s2.c_str())){
				CreateFolder(s2.c_str());
			}
			_mkdir(path);
		}
	}

}
//////////////////////////////////////////////////////////////////////////
//From MInputObserver
//////////////////////////////////////////////////////////////////////////
void CFileEngine::InputResponseEvent(TInt aEvent,const TDesC& aText)
{
	switch(aEvent)
	{
	case ECmdRenameFile:
		RenameFile(aText);
		break;

	case ECmdCreateFolder:
		CreateFolder(aText);
		break;

	case -1:
		break;

	default:
		ASSERT(EFalse);
		break;
	}
}
Exemple #25
0
HRESULT CFileHelper::CreateFolder(LPCTSTR path)
{
	BOOL b= FALSE;
	HRESULT hr = Contains(path, b);
	if(FAILED(hr)) return hr;

	if(b) return S_FALSE;

	String parent;
	hr = GetParentFolder(path, parent);
	if(FAILED(hr)) return hr;

	hr = CreateFolder(parent.c_str());
	if(FAILED(hr)) return hr;

#ifdef UNICODE
	return _wmkdir(path) == 0 ? S_OK : E_FAIL;
#else
	return _mkdir(path) == 0 ? S_OK : E_FAIL;
#endif
}
Exemple #26
0
// BrainUtil::CreateFile(_T("C:\\newFolderRoot\\newFolder\\newFile.txt"));
bool BrainUtil::CreateFile(const CString& fileFullName)
{
    if(DoesFileorFolderExist(fileFullName))
        return true;

    CString folderFullName = GetParentFolderName(fileFullName);
    if(!DoesFileorFolderExist(folderFullName))
    {
        bool bRet = CreateFolder(folderFullName); // Create the parent directory tree.
        if(!bRet)
            return false;
    }

    CString name = fileFullName;
    CString cmd;
    cmd.Format(_T("echo \"\" >> \"%s\""), name.GetBuffer());
    int ret = _wsystem(cmd.GetBuffer());
    DATA_ASSERT(0 == ret);
    bool bSucc = DoesFileorFolderExist(fileFullName);
    return bSucc;
}
Exemple #27
0
BOOL RKLOG_API RKLogVB(int lvl, LPCTSTR msg)
{
	static bool s_firstCall = true;
	static char szLvl[] = {'T', 'W', 'E', 'F', 'I'};

	if (s_firstCall) {
		s_firstCall = false;
		RKLClearLog();
	}

	if (lvl < 0 || lvl > 4) {
		return FALSE;
	}

	if (!CreateFolder(g_szLogPath)) {
		return FALSE;
	}

	BOOL ret;
	char fname[MAX_PATH];
	struct tm ltm;
	FILE *fp;

	WaitForSingleObject(g_hmtx, 500);

	fp = fopen(CreateLogName(fname, &ltm), "a+");
	if (fp) {
		fprintf(fp, "%c %02d:%02d:%02d <%s> %s\n", szLvl[lvl],
			ltm.tm_hour, ltm.tm_min, ltm.tm_sec, g_szLogModule, msg);
		fclose(fp);

		ret = TRUE;
	} else {
		ret = FALSE;
	}

	ReleaseMutex(g_hmtx);

	return ret;
}
Exemple #28
0
			// Read the content of the folder.
			void CMainWindow::ParseFolder(QTreeWidgetItem *p_pParent, const QDir &p_sCurrentFolder)
			{
				QStringList oStringList = p_sCurrentFolder.entryList(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot, QDir::Name);
				for(int nIndex = 0; nIndex < oStringList.size(); ++nIndex)
				{
					QFileInfo oInfo(p_sCurrentFolder.absoluteFilePath(oStringList[nIndex]));
					QString sPath = oInfo.absoluteFilePath();

					if(oInfo.isDir())
					{
						// Create the folder.
						QTreeWidgetItem *pChild = CreateFolder(p_pParent, sPath);

						ParseFolder(pChild, sPath);
					}
					// check if it isn't meta.
					else if(sPath.endsWith(".meta") == false)
					{												
						g_pRequestManager->RequestLoad(sPath);					
					}
				}
			}
Exemple #29
0
bool SaveToFile(LPCVOID data, DWORD length, const string_t& path,
                bool take_backup) {
  // Make sure the path is available
  CreateFolder(GetPathOnly(path));

  // Take a backup if needed
  if (take_backup) {
    std::wstring new_path = path + L".bak";
    MoveFileEx(path.c_str(), new_path.c_str(),
               MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH);
  }

  // Save the data
  BOOL result = FALSE;
  HANDLE file_handle = OpenFileForGenericWrite(path);
  if (file_handle != INVALID_HANDLE_VALUE) {
    DWORD bytes_written = 0;
    result = ::WriteFile(file_handle, data, length, &bytes_written, nullptr);
    ::CloseHandle(file_handle);
  }

  return result != FALSE;
}
BOOL initFS(char* OsFileName, int SizeInBlocks)
{
//	HANDLE hFile;

    fileSystemSizeInBlocks = SizeInBlocks;

    diskInBlocksSize = fileSystemSizeInBlocks * BLOCK_SIZE;

    createVirtualDisk(OsFileName, diskInBlocksSize);
    //openMapView(OsFileName, sizeInBlocks,hFile);
    CreateMyBitmap();
    CreateFolder();
    CreateOpenFiles();

    return 0;

}