Beispiel #1
0
void CRenameDlg::OnBnClickedButtonBrowseRef()
{
	CString ext;
	CString path;
	if (!m_originalName.IsEmpty())
	{
		CTGitPath origname(m_sBaseDir);
		origname.AppendPathString(m_originalName);
		ext = origname.GetFileExtension();
		path = origname.GetWinPathString();
	}

	if (CAppUtils::FileOpenSave(path, nullptr, AFX_IDD_FILESAVE, 0, false, GetSafeHwnd(), ext.Mid(1), !path.IsEmpty()))
	{
		GetDlgItem(IDC_NAME)->SetFocus();
		CTGitPath target(path);
		CString targetRoot;
		if (!target.HasAdminDir(&targetRoot) || g_Git.m_CurrentDir.CompareNoCase(targetRoot) != 0)
		{
			CMessageBox::Show(GetSafeHwnd(), IDS_ERR_MUSTBESAMEWT, IDS_APPNAME, MB_OK | MB_ICONEXCLAMATION);
			return;
		}
		CString relPath;
		m_sBaseDir.Replace(L"/", L"\\");
		if (!PathRelativePathTo(CStrBuf(relPath, MAX_PATH), m_sBaseDir, FILE_ATTRIBUTE_DIRECTORY, path, FILE_ATTRIBUTE_DIRECTORY))
			return;
		if (CStringUtils::StartsWith(relPath, L".\\"))
			relPath = relPath.Mid(2);
		m_name = relPath;
		UpdateData(FALSE);
	}
}
//***********************************************************************************************
CParticleWorkspace::CNode *CParticleWorkspace::addNode(const std::string &filenameWithFullPath)  throw( NLMISC::EStream)
{	
	nlassert(_OV);				
	// Check that file is not already inserted 	
	std::string fileName = NLMISC::CFile::getFilename(filenameWithFullPath);
	for(uint k = 0; k < _Nodes.size(); ++k)
	{
		if (NLMISC::nlstricmp(_Nodes[k]->getFilename(), fileName) == 0) return NULL;		
	}	
	char resultPath[MAX_PATH];
	std::string dosPath = NLMISC::CPath::standardizeDosPath(getPath());
	std::string relativePath;
	if (!PathRelativePathTo(resultPath, dosPath.c_str(), FILE_ATTRIBUTE_DIRECTORY, filenameWithFullPath.c_str(), 0))
	{
		relativePath = filenameWithFullPath; 
	}
	else
	{
		relativePath = resultPath;
	}
	if (relativePath.size() >= 2)
	{
		if (relativePath[0] == '\\' && relativePath[1] != '\\')
		{
			relativePath = relativePath.substr(1);
		}
	}
	CNode *newNode = new CNode;
	newNode->init(this);
	newNode->setRelativePath(relativePath);
	_Nodes.push_back(newNode);
	setModifiedFlag(true);
	return newNode;	
}
Beispiel #3
0
CString CPath::ConvertFullToRelativePath(CString sFullPath)
{
	// Declare variables
	CString sRelativePath, sBuffer;
	DWORD dwPathType;

	// Check if path is pointing to file or folder
	if (PathIsDirectory(sFullPath))
	{
		dwPathType = FILE_ATTRIBUTE_DIRECTORY;
	}
	else
	{
		dwPathType = FILE_ATTRIBUTE_NORMAL;
	}

	// Convert
	PathRelativePathTo(sBuffer.GetBuffer(_MAX_PATH), GetPathUpdater(), FILE_ATTRIBUTE_DIRECTORY, 
		sFullPath, dwPathType);

	// Get value of buffer
	sRelativePath = sBuffer.GetBuffer(sBuffer.GetLength());
	sBuffer.ReleaseBuffer();

	// Return result
	return sRelativePath;
}
Beispiel #4
0
CFileName CFileName::Relative(LPCTSTR compare,LPCTSTR current)
{
  CString rc;
  bool b=(TRUE==PathRelativePathTo(rc.GetBuffer(1+MAX_PATH),current,FILE_ATTRIBUTE_DIRECTORY,compare,0));
  rc.ReleaseBuffer();
  //TRACE(_T("compare=%s current=%s result=%s (b=%d)\n"),compare,current,b?rc:compare,b);
  return b?rc:compare;
} 
Beispiel #5
0
unsigned int skipper::directoryCheck(const std::wstring& directory)
{
    wchar_t relPath[MAX_PATH];
    if (!PathRelativePathTo(relPath, _toSkip.c_str(), FILE_ATTRIBUTE_DIRECTORY, directory.c_str(), FILE_ATTRIBUTE_DIRECTORY))
        return DIRECTORY_DONTCARE;
    if (relPath[0] == L'.' && relPath[1] == NULL)
        return DIRECTORY_EXCLUDE;
    return DIRECTORY_DONTCARE;
}
// Format a filename for saving
CString CTinyCadDoc::formatXMLFilename( const TCHAR *filename )
{
	
	TCHAR out[ MAX_PATH ];
	if (PathRelativePathTo( out, m_pParent->GetXMLPathName(), 0, filename, 0 ))
	{
		return out;
	}
	else
	{
		return filename;
	}
}
Beispiel #7
0
std::wstring CFileInfo::ConvertRelativePath(const wstring& szFullPath)
{
	TCHAR		szRelativePath[MAX_PATH] = L"";
	TCHAR		szDirtoryPath[MAX_PATH] = L"";

	GetCurrentDirectory(sizeof(szDirtoryPath), szDirtoryPath);
	PathRelativePathTo((LPWSTR)szRelativePath
		, szDirtoryPath
		, FILE_ATTRIBUTE_DIRECTORY
		, szFullPath.c_str()
		, FILE_ATTRIBUTE_NORMAL);

	return szRelativePath;
}
Beispiel #8
0
CFilePath CFilePath::RelativePathTo(
    LPCTSTR psPathTo,
    BOOL bSrcIsDir)
{
    CString sPath;

    if (!psPathTo)
        return CFilePath();

    int nMaxLen = 3 * msPath.GetLength() / 2 + 1  + _tcslen(psPathTo);

    PathRelativePathTo(CStringLock(sPath, nMaxLen), msPath, bSrcIsDir ? FILE_ATTRIBUTE_DIRECTORY : 0, psPathTo, 0);

    return CFilePath(sPath, 0);
}
Beispiel #9
0
/*
    010509 Carl Corcoran
*/
void CCString::Path_AbsoluteToRelative(PCWSTR wszNewRoot)
{
    WCHAR wszNewString[MAX_PATH];
    WCHAR wszCanonString[MAX_PATH];

    PathRelativePathTo(wszNewString,
        wszNewRoot, FILE_ATTRIBUTE_DIRECTORY,
        this->wszString, FILE_ATTRIBUTE_NORMAL
        );

    PathCanonicalize(wszCanonString, wszNewString);

    this->cpy(wszCanonString);

    return;
}
Beispiel #10
0
	WString FilePath::GetRelativePathFor(const FilePath& _filePath)
	{
		if (_fullPath.Length()==0 || _filePath._fullPath.Length()==0 || _fullPath[0] != _filePath._fullPath[0])
		{
			return _filePath._fullPath;
		}
		wchar_t buffer[MAX_PATH + 1] = { 0 };
		PathRelativePathTo(
			buffer,
			_fullPath.Buffer(),
			(IsFolder() ? FILE_ATTRIBUTE_DIRECTORY : 0),
			_filePath._fullPath.Buffer(),
			(_filePath.IsFolder() ? FILE_ATTRIBUTE_DIRECTORY : 0)
			);
		return buffer;
	}
Beispiel #11
0
		WString FilePath::GetRelativePathFor(const FilePath& _filePath)
		{
			if (fullPath.Length()==0 || _filePath.fullPath.Length()==0 || fullPath[0] != _filePath.fullPath[0])
			{
				return _filePath.fullPath;
			}
#if defined VCZH_MSVC
			wchar_t buffer[MAX_PATH + 1] = { 0 };
			PathRelativePathTo(
				buffer,
				fullPath.Buffer(),
				(IsFolder() ? FILE_ATTRIBUTE_DIRECTORY : 0),
				_filePath.fullPath.Buffer(),
				(_filePath.IsFolder() ? FILE_ATTRIBUTE_DIRECTORY : 0)
				);
			return buffer;
#elif defined VCZH_GCC
			collections::List<WString> srcComponents, tgtComponents, resultComponents;
			GetPathComponents(IsFolder() ? fullPath : GetFolder().GetFullPath(), srcComponents);
			GetPathComponents(_filePath.fullPath, tgtComponents);

			int minLength = srcComponents.Count() <= tgtComponents.Count() ? srcComponents.Count() : tgtComponents.Count();
			int lastCommonComponent = 0;
			for(int i = 0; i < minLength; i++)
			{
				if(srcComponents[i] == tgtComponents[i])
				{
					lastCommonComponent = i;
				}
				else
					break;
			}

			for(int i = lastCommonComponent + 1; i < srcComponents.Count(); i++)
			{
				resultComponents.Add(L"..");
			}

			for(int i = lastCommonComponent + 1; i < tgtComponents.Count(); i++)
			{
				resultComponents.Add(tgtComponents[i]);
			}

			return ComponentsToPath(resultComponents);
#endif
		}
Beispiel #12
0
CString CPathFinder::GetRelativePath(LPCTSTR szBaseFolder)
{
	if (IsRelativePath()) return (LPCTSTR)sCEmptyString;

	TCHAR	szRelativePath[_MAX_PATH];
	CString	sRelPath;

	PathRelativePathTo(szRelativePath, szBaseFolder, FILE_ATTRIBUTE_DIRECTORY, 
					GetPath(), IsFilePath() ? 0 : FILE_ATTRIBUTE_DIRECTORY);

	sRelPath = szRelativePath;
	if (sRelPath.GetLength() > 1)
	{
		// Remove ".\" from the beginning
		if ((sRelPath[0] == '.') && (sRelPath[1] == '\\'))
			sRelPath.Right(sRelPath.GetLength() - 2);
	}

	return sRelPath;
}
	static path relative_to(const path &from, const path &to, bool fromdir=true) {
		if(PathIsSameRoot(from.buf, to.buf)) {
			path p;

			if(!PathRelativePathTo(p.buf, from.buf, fromdir?FILE_ATTRIBUTE_DIRECTORY:0, to.buf, 0))
			{
				TCHAR chBuf[1024];
				swprintf_s(chBuf, _countof(chBuf), L"PathRelativePathTo() from:[%s] to:[%s] failed!!", from.buf, to.buf);
				TRACEERR("[path] [relative_to]", chBuf, GetLastError());
				throw path_error("PathRelativePathTo");
			}

			return p;
		}
		else if(to.has_root()) return to;
		else
		{
			TRACEE("[path] [relative_to]  * ERROR:  unable to create relative path: paths have different roots!!");
			throw std::runtime_error("unable to create relative path: paths have different roots");
		}
	}
Beispiel #14
0
	std::string OpenFile(HWindow hwnd, char* filter){
		char masterDir[512];
		GetCurrentDirectory(512, masterDir);
		static std::string sLastDir = masterDir;
		char szFile[260];
		OPENFILENAME ofn;
		ZeroMemory(&ofn, sizeof(ofn));
		ofn.lStructSize = sizeof(ofn);
		ofn.hwndOwner = (HWND)hwnd;
		ofn.lpstrFile = szFile;
		// Set lpstrFile[0] to '\0' so that GetOpenFileName does not 
		// use the contents of szFile to initialize itself.
		ofn.lpstrFile[0] = '\0';
		ofn.nMaxFile = sizeof(szFile);
		ofn.lpstrFilter = filter; // "All\0*.*\0Text\0*.TXT\0\0";
		ofn.nFilterIndex = 1;
		ofn.lpstrFileTitle = NULL;
		ofn.nMaxFileTitle = 0;
		ofn.lpstrInitialDir = sLastDir.c_str();
		ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;

		if (GetOpenFileName(&ofn)){
			char newDirectory[512];
			GetCurrentDirectory(512, newDirectory);
			sLastDir = newDirectory;
			SetCurrentDirectory(masterDir);
			char relative[512];
			PathRelativePathTo(relative, masterDir, FILE_ATTRIBUTE_DIRECTORY, szFile, FILE_ATTRIBUTE_NORMAL);
			return std::string(relative);
		}
		char newDirectory[512];
		GetCurrentDirectory(512, newDirectory);
		sLastDir = newDirectory;
		SetCurrentDirectory(masterDir);
		return std::string();
	}
Beispiel #15
0
VOID AddFileFromFileDialog(HWND hWnd)
{
	TCHAR FileName[MAX_PATH], RelPath[MAX_PATH], CurrentWorkingDir[MAX_PATH];
	TCHAR Command[2*MAX_PATH];

    GetCurrentDirectory(MAX_PATH,CurrentWorkingDir);

	if (ShowOpenFileDialog(hWnd, FileName)) {
		AddMruFile(FileName);
		

		PathRelativePathTo(RelPath,
                       CurrentWorkingDir,
                       FILE_ATTRIBUTE_DIRECTORY,
                       FileName,
                       FILE_ATTRIBUTE_NORMAL);


		wsprintf(Command, TEXT(":add %s"), ExpandFileName(RelPath));
		FireCommand(Command);
	}

    SetCurrentDirectory(CurrentWorkingDir);
}
void CObjectTool::OnStaticMeshLoad()
{
	// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.

	HRESULT hr = NULL;
	CFileFind finder, texfinder;
	BOOL bWorking = false;
	BOOL bTexWorking = false;

	wofstream SaveFile, SaveTex;

	bWorking = finder.FindFile(_T("..//Resource/Mesh/*.*"));
	bTexWorking = texfinder.FindFile(_T("..//Resource/MeshImage/*.png"));
	SaveFile.open(L"..//Resource/MeshPath.txt", ios::out);
	SaveTex.open(L"..//Resource/MeshTexPath.txt", ios::out);

	GetDlgItem(IDC_BUTTON3)->EnableWindow(FALSE);

	while (bTexWorking)
	{
		bTexWorking = texfinder.FindNextFileW();
		if (!texfinder.IsDirectory() && !texfinder.IsDots())
		{
			CString TexturePath = texfinder.GetFilePath();//경로
			CString TextureKey = texfinder.GetFileName();//키값

			TCHAR* tcFilePath = new TCHAR[128];
			wsprintf(tcFilePath, TexturePath);
			TCHAR* tcFileKey = new TCHAR[128];
			wsprintf(tcFileKey, TextureKey);

			if (m_bFirstLoad == false)
			{
				vecTexKey.push_back(tcFileKey);
				vecTexPath.push_back(tcFilePath);
			}
		}
	}

	if (m_bFirstLoad == false)
	{
		vector<TCHAR*>::iterator Pathiter = vecTexPath.begin();
		vector<TCHAR*>::iterator Keyiter = vecTexKey.begin();
		vector<TCHAR*>::iterator Pathiter_End = vecTexPath.end();
		vector<TCHAR*>::iterator Keyiter_End = vecTexKey.end();

		bool bEndofVector = false;

		while (!bEndofVector)
		{
			if (FAILED(CResourcesMgr::GetInstance()->AddTexture(
				RESOURCE_STAGE
				, (*Keyiter)
				, (*Pathiter))))
			{
				MessageBox(L"Texture Load Failed", *Keyiter);
			}

			TCHAR szPath[MAX_PATH] = L"";
			TCHAR szDirPath[MAX_PATH] = L"";
			GetCurrentDirectory(sizeof(szDirPath), szDirPath);

			PathRelativePathTo((LPWSTR)szPath,
				szDirPath, FILE_ATTRIBUTE_DIRECTORY,
				*Pathiter, FILE_ATTRIBUTE_NORMAL);

			SaveTex << (*Keyiter) << L"|";
			SaveTex << szPath << endl;


			++Keyiter;
			++Pathiter;

			if (Keyiter == Keyiter_End && Pathiter == Pathiter_End)
			{
				bEndofVector = true;
			}

		}

		bEndofVector = false;

		while (!bEndofVector)
		{
			vecTexKey.pop_back();
			vecTexPath.pop_back();
			if (vecTexKey.size() == 0 && vecTexPath.size() == 0)
			{
				bEndofVector = true;
				vecTexKey.clear();
				vecTexPath.clear();
				break;
			}

		}
	}


	while (bWorking)
	{
		bWorking = finder.FindNextFileW();
		if (finder.IsDirectory() && finder.IsDots())
			continue;
		else
		{
			CString FilePath = finder.GetFilePath();//경로
			PathRemoveFileSpec((LPWSTR)(LPCTSTR)FilePath);//파일 이름을 날린다
			CString FileKey = finder.GetFileName();//컴포넌트 키값
			PathRemoveExtension((LPWSTR)(LPCTSTR)FileKey);//확장자 날린다
			CString FileName = finder.GetFileName();//fbx파일


			TCHAR* tcFilePath = new TCHAR[128];
			wsprintf(tcFilePath, FilePath);
			_tcscat(tcFilePath, _T("\\"));
			TCHAR* tcFileKey = new TCHAR[128];
			wsprintf(tcFileKey, FileKey);
			TCHAR* tcFileName = new TCHAR[128];
			wsprintf(tcFileName, FileName);


			if (m_bFirstLoad == false)
			{
				vecFileKey.push_back(tcFileKey);
				vecFilename.push_back(tcFileName);
				vecFilePath.push_back(tcFilePath);
			}

			m_StaticList.AddString((LPWSTR)(LPCTSTR)FileKey);
		}

	}


	if (m_bFirstLoad == false)
	{
		vector<TCHAR*>::iterator Pathiter = vecFilePath.begin();
		vector<TCHAR*>::iterator Nameiter = vecFilename.begin();
		vector<TCHAR*>::iterator Keyiter = vecFileKey.begin();
		vector<TCHAR*>::iterator Pathiter_End = vecFilePath.end();
		vector<TCHAR*>::iterator Nameiter_End = vecFilename.end();
		vector<TCHAR*>::iterator Keyiter_End = vecFileKey.end();

		bool bEndofVector = false;

		while (!bEndofVector)
		{
			int len = 128;
			char cPath[128];
			char cName[128];

			WideCharToMultiByte(CP_ACP, 0, (*Pathiter), len, cPath, len, NULL, NULL);
			WideCharToMultiByte(CP_ACP, 0, (*Nameiter), len, cName, len, NULL, NULL);


			if (FAILED(CResourcesMgr::GetInstance()->AddMesh(
				RESOURCE_STAGE,
				MESH_STATIC
				, (*Keyiter)
				, "..\\Resource\\Mesh\\"
				, cName)))
			{
				MessageBox(L"Mesh Load Failed Or Aready Exist Mesh", *Nameiter);
			}

			TCHAR szPath[MAX_PATH] = L"";
			TCHAR szDirPath[MAX_PATH] = L"";
			GetCurrentDirectory(sizeof(szDirPath), szDirPath);

			PathRelativePathTo((LPWSTR)szPath,
				szDirPath, FILE_ATTRIBUTE_DIRECTORY,
				*Pathiter, FILE_ATTRIBUTE_NORMAL);

			SaveFile << (*Keyiter) << L"|";
			SaveFile << szPath << L"|";
			SaveFile << (*Nameiter) << endl;


			++Keyiter;
			++Pathiter;
			++Nameiter;

			if (Keyiter == Keyiter_End && Pathiter == Pathiter_End && Nameiter == Nameiter_End)
			{
				bEndofVector = true;
			}

		}


		bEndofVector = false;

		while (!bEndofVector)
		{
			vecFileKey.pop_back();
			vecFilename.pop_back();
			vecFilePath.pop_back();
			if (vecFileKey.size() == 0 && vecFilePath.size() == 0 && vecFilename.size() == 0)
			{
				bEndofVector = true;
				vecFileKey.clear();
				vecFilename.clear();
				vecFilePath.clear();
				break;
			}

		}
		m_bFirstLoad = true;
	}

	SaveTex.close();

	SaveFile.close();

}
Beispiel #17
0
nfsstat3 CNFS3Prog::ProcedureREADLINK(void)
{
    PrintLog("READLINK");
    char *path;
    char *pMBBuffer = 0;

    post_op_attr symlink_attributes;
    nfspath3 data = nfspath3();

    //opaque data;
    nfsstat3 stat;

    HANDLE hFile;
    REPARSE_DATA_BUFFER *lpOutBuffer;
    lpOutBuffer = (REPARSE_DATA_BUFFER*)malloc(MAXIMUM_REPARSE_DATA_BUFFER_SIZE);
    DWORD bytesReturned;

    path = GetPath();
    stat = CheckFile(path);
    if (stat == NFS3_OK) {

        hFile = CreateFile(path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_REPARSE_POINT | FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS, NULL);

        if (hFile == INVALID_HANDLE_VALUE) {
            stat = NFS3ERR_IO;
        }
        else
        {
            lpOutBuffer = (REPARSE_DATA_BUFFER*)malloc(MAXIMUM_REPARSE_DATA_BUFFER_SIZE);
            if (!lpOutBuffer) {
                stat = NFS3ERR_IO;
            }
            else {
                DeviceIoControl(hFile, FSCTL_GET_REPARSE_POINT, NULL, 0, lpOutBuffer, MAXIMUM_REPARSE_DATA_BUFFER_SIZE, &bytesReturned, NULL);

                if (lpOutBuffer->ReparseTag == IO_REPARSE_TAG_SYMLINK || lpOutBuffer->ReparseTag == IO_REPARSE_TAG_MOUNT_POINT)
                {
                    if (lpOutBuffer->ReparseTag == IO_REPARSE_TAG_SYMLINK)
                    {
                        size_t plen = lpOutBuffer->SymbolicLinkReparseBuffer.PrintNameLength / sizeof(WCHAR);
                        pMBBuffer = (char *)malloc((plen + 1));
                        WCHAR *szPrintName = new WCHAR[plen + 1];
                        wcsncpy_s(szPrintName, plen + 1, &lpOutBuffer->SymbolicLinkReparseBuffer.PathBuffer[lpOutBuffer->SymbolicLinkReparseBuffer.PrintNameOffset / sizeof(WCHAR)], plen);
                        szPrintName[plen] = 0;
                        size_t i;
                        wcstombs_s(&i, pMBBuffer, (plen + 1), szPrintName, (plen + 1));
                        // TODO: Revisit with cleaner solution
                        if (!PathIsRelative(pMBBuffer))
                        {
                            std::string strFromChar;
                            strFromChar.append("\\\\?\\");
                            strFromChar.append(pMBBuffer);
                            char *target = _strdup(strFromChar.c_str());
                            // remove last folder
                            char *pos = strrchr(path, '\\');
                            if (pos != NULL) {
                                *pos = '\0';
                            }
                            PathRelativePathTo(pMBBuffer, path, FILE_ATTRIBUTE_DIRECTORY, target, FILE_ATTRIBUTE_DIRECTORY);
                        }
                    }

                    // TODO: Revisit with cleaner solution
                    if (lpOutBuffer->ReparseTag == IO_REPARSE_TAG_MOUNT_POINT)
                    {
                        size_t slen = lpOutBuffer->MountPointReparseBuffer.SubstituteNameLength / sizeof(WCHAR);
                        pMBBuffer = (char *)malloc((slen + 1));
                        WCHAR *szSubName = new WCHAR[slen + 1];
                        wcsncpy_s(szSubName, slen + 1, &lpOutBuffer->MountPointReparseBuffer.PathBuffer[lpOutBuffer->MountPointReparseBuffer.SubstituteNameOffset / sizeof(WCHAR)], slen);
                        szSubName[slen] = 0;
                        std::wstring wStringTemp(szSubName);
                        std::string target(wStringTemp.begin(), wStringTemp.end());
                        target.erase(0, 2);
                        target.insert(0, 2, '\\');
                        // remove last folder, see above
                        char *pos = strrchr(path, '\\');
                        if (pos != NULL) {
                            *pos = '\0';
                        }
                        PathRelativePathTo(pMBBuffer, path, FILE_ATTRIBUTE_DIRECTORY, target.c_str(), FILE_ATTRIBUTE_DIRECTORY);
                    }

                    // write path always with / separator, so windows created symlinks work too
                    std::string strFromChar;
                    strFromChar.append(pMBBuffer);
                    std::replace(strFromChar.begin(), strFromChar.end(), '\\', '/');
                    char *result = _strdup(strFromChar.c_str());

                    data.Set(result);
                    free(pMBBuffer);
                    free(result);
                }
                free(lpOutBuffer);
            }
        }
        CloseHandle(hFile);
    }

    symlink_attributes.attributes_follow = GetFileAttributesForNFS(path, &symlink_attributes.attributes);

    Write(&stat);
    Write(&symlink_attributes);
    if (stat == NFS3_OK) {
        Write(&data);
    }

    return stat;
}
/** 
 * Upload locally built symbols to network symbol storage.
 *
 * Use case:
 *   Game designers use game from source (without prebuild game .dll-files).
 *   In this case all game .dll-files are compiled locally.
 *   For post-mortem debug programmers need .dll and .pdb files from designers.
 */
bool FWindowsPlatformStackWalk::UploadLocalSymbols()
{
	InitStackWalking();

#if WINVER > 0x502
	// Upload locally compiled files to symbol storage.
	FString SymbolStorage;
	if (!GConfig->GetString( CrashReporterSettings, TEXT( "UploadSymbolsPath" ), SymbolStorage, GEditorPerProjectIni ) || SymbolStorage.IsEmpty())
	{
		// Nothing to do.
		return true;
	}
	// Prepare string
	SymbolStorage.ReplaceInline( TEXT( "/" ), TEXT( "\\" ), ESearchCase::CaseSensitive );
	SymbolStorage = TEXT( "SRV*" ) + SymbolStorage;

	int32 ErrorCode = 0;
	HANDLE ProcessHandle = GetCurrentProcess();

	// Enumerate process modules.
	HMODULE* ModuleHandlePointer = GetProcessModules( ProcessHandle );
	if (!ModuleHandlePointer)
	{
		ErrorCode = GetLastError();
		return false;
	}

#if WITH_EDITOR
	// Get Unreal Engine Editor directory for detecting non-game editor binaries.
	FString EnginePath = FPaths::ConvertRelativePathToFull( FPaths::EngineDir() );
	FPaths::MakePlatformFilename( EnginePath );
#endif

	// Upload all locally built modules.
	for (int32 ModuleIndex = 0; ModuleHandlePointer[ModuleIndex]; ModuleIndex++)
	{
		WCHAR ImageName[MAX_PATH] = {0};
		FGetModuleFileNameEx( ProcessHandle, ModuleHandlePointer[ModuleIndex], ImageName, MAX_PATH );

#if WITH_EDITOR
		WCHAR RelativePath[MAX_PATH];
		// Skip binaries inside Unreal Engine Editor directory (non-game editor binaries)
		if (PathRelativePathTo( RelativePath, *EnginePath, FILE_ATTRIBUTE_DIRECTORY, ImageName, 0 ) && FCString::Strncmp( RelativePath, TEXT( "..\\" ), 3 ))
		{
			continue;
		}
#endif

		WCHAR DebugName[MAX_PATH];
		FCString::Strcpy( DebugName, ImageName );

		if (PathRenameExtensionW( DebugName, L".pdb" ))
		{
			// Upload only if found .pdb file
			if (PathFileExistsW( DebugName ))
			{
				// Upload original file
				UE_LOG( LogWindows, Log, TEXT( "Uploading to symbol storage: %s" ), ImageName );
				if (!SymSrvStoreFileW( ProcessHandle, *SymbolStorage, ImageName, SYMSTOREOPT_PASS_IF_EXISTS ))
				{
					UE_LOG( LogWindows, Warning, TEXT( "Uploading to symbol storage failed: %s. Error: %d" ), ImageName, GetLastError() );
				}

				// Upload debug symbols
				UE_LOG( LogWindows, Log, TEXT( "Uploading to symbol storage: %s" ), DebugName );
				if (!SymSrvStoreFileW( ProcessHandle, *SymbolStorage, DebugName, SYMSTOREOPT_PASS_IF_EXISTS ))
				{
					UE_LOG( LogWindows, Warning, TEXT( "Uploading to symbol storage failed: %s. Error: %d" ), DebugName, GetLastError() );
				}
			}
		}
	}
#else
	UE_LOG( LogWindows, Log, TEXT( "Symbol server not supported on Windows XP." ) );
#endif
	return true;
}