C++ PathFileExists函数代码示例

本文整理汇总了C++中PathFileExists函数的典型用法代码示例。如果您正苦于以下问题:C++ PathFileExists函数的具体用法?C++ PathFileExists怎么用?C++ PathFileExists使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


C++ PathFileExists函数代码示例

在下文中一共展示了PathFileExists函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: changed

bool Buffer::checkFileState() {	//returns true if the status has been changed (it can change into DOC_REGULAR too). false otherwise
	struct _stat buf;

 	if (_currentStatus == DOC_UNNAMED)	//unsaved document cannot change by environment
		return false;

	bool isWow64Off = false;
	NppParameters *pNppParam = NppParameters::getInstance();
	if (!PathFileExists(_fullPathName.c_str()))
	{
		pNppParam->safeWow64EnableWow64FsRedirection(FALSE);
		isWow64Off = true;
	}

	bool isOK = false;
	if (_currentStatus != DOC_DELETED && !PathFileExists(_fullPathName.c_str()))	//document has been deleted
	{
		_currentStatus = DOC_DELETED;
		_isFileReadOnly = false;
		_isDirty = true;	//dirty sicne no match with filesystem
		_timeStamp = 0;
		doNotify(BufferChangeStatus | BufferChangeReadonly | BufferChangeTimestamp);
		isOK = true;
	} 
	else if (_currentStatus == DOC_DELETED && PathFileExists(_fullPathName.c_str())) 
	{	//document has returned from its grave
		if (!generic_stat(_fullPathName.c_str(), &buf))
		{
			_isFileReadOnly = (bool)(!(buf.st_mode & _S_IWRITE));

			_currentStatus = DOC_MODIFIED;
			_timeStamp = buf.st_mtime;
			doNotify(BufferChangeStatus | BufferChangeReadonly | BufferChangeTimestamp);
			isOK = true;
		}
	}
	else if (!generic_stat(_fullPathName.c_str(), &buf))
	{
		int mask = 0;	//status always 'changes', even if from modified to modified
		bool isFileReadOnly = (bool)(!(buf.st_mode & _S_IWRITE));
		if (isFileReadOnly != _isFileReadOnly)
		{
			_isFileReadOnly = isFileReadOnly;
			mask |= BufferChangeReadonly;
		}
		if (_timeStamp != buf.st_mtime)
		{
			_timeStamp = buf.st_mtime;
			mask |= BufferChangeTimestamp;
			_currentStatus = DOC_MODIFIED;
			mask |= BufferChangeStatus;	//status always 'changes', even if from modified to modified
		}

		if (mask != 0) 
		{
			doNotify(mask);
			isOK = true;
		}
		isOK = false;
	}
	
	if (isWow64Off)
	{
		pNppParam->safeWow64EnableWow64FsRedirection(TRUE);
		isWow64Off = false;
	}
	return isOK;
}
开发者ID:Tanjas5,项目名称:npp,代码行数:68,代码来源:Buffer.cpp

示例2: UpdateData

void COpenDlg::OnOK()
{
	UpdateData(TRUE);

	bool bUDiffOnClipboard = false;
	if (OpenClipboard())
	{
		UINT enumFormat = 0;
		do 
		{
			if (enumFormat == m_cFormat)
			{
				bUDiffOnClipboard = true;
			}
		} while((enumFormat = EnumClipboardFormats(enumFormat))!=0);
		CloseClipboard();
	}

	if (GetDlgItem(IDC_BASEFILEEDIT)->IsWindowEnabled())
	{
		m_sUnifiedDiffFile.Empty();
		m_sPatchDirectory.Empty();
	}
	else
	{
		m_sBaseFile.Empty();
		m_sYourFile.Empty();
		m_sTheirFile.Empty();
	}
	UpdateData(FALSE);
	CString sFile;
	if (!m_sUnifiedDiffFile.IsEmpty())
		if (!PathFileExists(m_sUnifiedDiffFile))
			sFile = m_sUnifiedDiffFile;
	if (!m_sPatchDirectory.IsEmpty())
		if (!PathFileExists(m_sPatchDirectory))
			sFile = m_sPatchDirectory;
	if (!m_sBaseFile.IsEmpty())
		if (!PathFileExists(m_sBaseFile))
			sFile = m_sBaseFile;
	if (!m_sYourFile.IsEmpty())
		if (!PathFileExists(m_sYourFile))
			sFile = m_sYourFile;
	if (!m_sTheirFile.IsEmpty())
		if (!PathFileExists(m_sTheirFile))
			sFile = m_sTheirFile;

	if (bUDiffOnClipboard && m_bFromClipboard)
	{
		if (OpenClipboard()) 
		{ 
			HGLOBAL hglb = GetClipboardData(m_cFormat); 
			LPCSTR lpstr = (LPCSTR)GlobalLock(hglb); 

			DWORD len = GetTempPath(0, NULL);
			TCHAR * path = new TCHAR[len+1];
			TCHAR * tempF = new TCHAR[len+100];
			GetTempPath (len+1, path);
			GetTempFileName (path, TEXT("tsm"), 0, tempF);
			CString sTempFile = CString(tempF);
			delete [] path;
			delete [] tempF;

			FILE * outFile;
			size_t patchlen = strlen(lpstr);
			_tfopen_s(&outFile, sTempFile, _T("wb"));
			if(outFile)
			{
				size_t size = fwrite(lpstr, sizeof(char), patchlen, outFile);
				if (size < patchlen)
					bUDiffOnClipboard = false;
				else
				{
					m_sUnifiedDiffFile = sTempFile;
					UpdateData(FALSE);
					sFile.Empty();
				}
				fclose(outFile);
			}
			GlobalUnlock(hglb); 
			CloseClipboard(); 
		} 

	}

	if (!sFile.IsEmpty())
	{
		CString sErr;
		sErr.Format(IDS_ERR_PATCH_INVALIDPATCHFILE, (LPCTSTR)sFile);
		MessageBox(sErr, NULL, MB_ICONERROR);
		return;
	}
	CDialog::OnOK();
}
开发者ID:andmedsantana,项目名称:TortoiseGit,代码行数:94,代码来源:OpenDlg.cpp

示例3: ExtendFrameIntoClientArea

BOOL CExportDlg::OnInitDialog()
{
    CResizableStandAloneDialog::OnInitDialog();
    CAppUtils::MarkWindowAsUnpinnable(m_hWnd);

    ExtendFrameIntoClientArea(IDC_REVISIONGROUP);
    m_aeroControls.SubclassOkCancelHelp(this);

    m_sExportDirOrig = m_strExportDirectory;
    m_bAutoCreateTargetName = !(PathIsDirectoryEmpty(m_sExportDirOrig) || !PathFileExists(m_sExportDirOrig));

    AdjustControlSize(IDC_NOEXTERNALS);
    AdjustControlSize(IDC_IGNOREKEYWORDS);
    AdjustControlSize(IDC_REVISION_HEAD);
    AdjustControlSize(IDC_REVISION_N);

    AddAnchor(IDC_REPOGROUP, TOP_LEFT, TOP_RIGHT);
    AddAnchor(IDC_REPOLABEL, TOP_LEFT);
    AddAnchor(IDC_URLCOMBO, TOP_LEFT, TOP_RIGHT);
    AddAnchor(IDC_BROWSE, TOP_RIGHT);
    AddAnchor(IDC_EXPORT_CHECKOUTDIR, TOP_LEFT);
    AddAnchor(IDC_CHECKOUTDIRECTORY, TOP_LEFT, TOP_RIGHT);
    AddAnchor(IDC_CHECKOUTDIRECTORY_BROWSE, TOP_RIGHT);
    AddAnchor(IDC_DEPTH, TOP_LEFT, TOP_RIGHT);
    AddAnchor(IDC_NOEXTERNALS, TOP_LEFT);
    AddAnchor(IDC_IGNOREKEYWORDS, TOP_LEFT);
    AddAnchor(IDC_EOLLABEL, TOP_LEFT);
    AddAnchor(IDC_EOLCOMBO, TOP_LEFT);

    AddAnchor(IDC_REVISIONGROUP, TOP_LEFT, BOTTOM_RIGHT);
    AddAnchor(IDC_REVISION_HEAD, TOP_LEFT);
    AddAnchor(IDC_REVISION_N, TOP_LEFT);
    AddAnchor(IDC_REVISION_NUM, TOP_LEFT);
    AddAnchor(IDC_SHOW_LOG, TOP_LEFT);

    AddAnchor(IDOK, BOTTOM_RIGHT);
    AddAnchor(IDCANCEL, BOTTOM_RIGHT);
    AddAnchor(IDHELP, BOTTOM_RIGHT);

    // save the provided url since the url combo
    // will change that below
    CString origurl = m_URL;
    m_URLCombo.SetURLHistory(true, true);
    m_URLCombo.LoadHistory(L"Software\\TortoiseSVN\\History\\repoURLS", L"url");
    m_URLCombo.SetCurSel(0);

    m_depthCombo.AddString(CString(MAKEINTRESOURCE(IDS_SVN_DEPTH_INFINITE)));
    m_depthCombo.AddString(CString(MAKEINTRESOURCE(IDS_SVN_DEPTH_IMMEDIATE)));
    m_depthCombo.AddString(CString(MAKEINTRESOURCE(IDS_SVN_DEPTH_FILES)));
    m_depthCombo.AddString(CString(MAKEINTRESOURCE(IDS_SVN_DEPTH_EMPTY)));
    m_depthCombo.SetCurSel(0);

    // set radio buttons according to the revision
    SetRevision(Revision);

    m_editRevision.SetWindowText(L"");

    if (!origurl.IsEmpty())
        m_URLCombo.SetWindowText(origurl);
    else
    {
        // if there is an url on the clipboard, use that url as the default.
        CAppUtils::AddClipboardUrlToWindow(m_URLCombo.GetSafeHwnd());
    }
    GetDlgItem(IDC_BROWSE)->EnableWindow(!m_URLCombo.GetString().IsEmpty());

    m_tooltips.AddTool(IDC_CHECKOUTDIRECTORY, IDS_CHECKOUT_TT_DIR);
    m_tooltips.AddTool(IDC_EOLCOMBO, IDS_EXPORT_TT_EOL);

    SHAutoComplete(GetDlgItem(IDC_CHECKOUTDIRECTORY)->m_hWnd, SHACF_FILESYSTEM);

    // fill the combobox with the choices of eol styles
    m_eolCombo.AddString(L"default");
    m_eolCombo.AddString(L"CRLF");
    m_eolCombo.AddString(L"LF");
    m_eolCombo.AddString(L"CR");
    m_eolCombo.SelectString(0, L"default");

    if (!Revision.IsHead())
    {
        // if the revision is not HEAD, change the radio button and
        // fill in the revision in the edit box
        CString temp;
        temp.Format(L"%ld", (LONG)Revision);
        m_editRevision.SetWindowText(temp);
        CheckRadioButton(IDC_REVISION_HEAD, IDC_REVISION_N, IDC_REVISION_N);
    }

    DialogEnableWindow(IDOK, !m_strExportDirectory.IsEmpty());

    if ((m_pParentWnd==NULL)&&(GetExplorerHWND()))
        CenterWindow(CWnd::FromHandle(GetExplorerHWND()));
    EnableSaveRestore(L"ExportDlg");
    return TRUE;
}
开发者ID:Kasper8660,项目名称:tortoisesvn,代码行数:95,代码来源:ExportDlg.cpp

示例4: GetFileCRC32

bool GetFileCRC32(const TCHAR* pszFileName, unsigned& uCrc32)
{
    bool    bRetCode    = false;
    HANDLE  hFileMap    = NULL;
    HANDLE  hFile       = INVALID_HANDLE_VALUE;
    void*   pView       = NULL;
    DWORD   dwFileSize  = 0;

    if(NULL == pszFileName)
        goto Exit0;

    uCrc32 = 0;

    //Check file exist
    if(!PathFileExists(pszFileName))
        goto Exit0;

    //Create file
    hFile = CreateFile(pszFileName,
        GENERIC_READ,
        FILE_SHARE_READ,
        NULL,
        OPEN_EXISTING,
        FILE_ATTRIBUTE_NORMAL,
        NULL
    );
    if(INVALID_HANDLE_VALUE == hFile)
        goto Exit0;

    //Get size of file
    dwFileSize = GetFileSize(hFile, NULL);
    if(INVALID_FILE_SIZE == dwFileSize)
        goto Exit0;

    //Create file mapping
    hFileMap = CreateFileMapping(hFile,
        NULL,
        PAGE_READONLY,
        0,
        dwFileSize,
        NULL
    );
    if(NULL == hFileMap)
        goto Exit0;

    pView = MapViewOfFile(hFileMap,
        FILE_MAP_READ,
        0,
        0,
        dwFileSize
    );
    if(NULL == pView)
        goto Exit0;

    //Compute the CRC32 value of file
    uCrc32 = CRC32(uCrc32, pView, dwFileSize);

    bRetCode = true; 
Exit0:
    if(NULL != pView)
    {
        UnmapViewOfFile(pView);
        pView = NULL;
    }
    if(NULL != hFileMap)
    {
        CloseHandle(hFileMap);
        hFileMap = NULL;
    }
    if(hFile != INVALID_HANDLE_VALUE)
    {
        CloseHandle(hFile);
        hFile = INVALID_HANDLE_VALUE;
    }
    return bRetCode;
}
开发者ID:1050676515,项目名称:zpublic,代码行数:76,代码来源:FileCRC32.cpp

示例5: SecureZeroMemory

BOOL CPOFile::SaveFile(LPCTSTR szPath, LPCTSTR lpszHeaderFile)
{
    //since stream classes still expect the filepath in char and not wchar_t
    //we need to convert the filepath to multibyte
    char filepath[MAX_PATH + 1] = { 0 };
    int nEntries = 0;
    SecureZeroMemory(filepath, sizeof(filepath));
    WideCharToMultiByte(CP_ACP, NULL, szPath, -1, filepath, _countof(filepath)-1, NULL, NULL);

    std::wofstream File;
    File.imbue(std::locale(std::locale(), new utf8_conversion()));
    File.open(filepath, std::ios_base::binary);

    if ((lpszHeaderFile)&&(lpszHeaderFile[0])&&(PathFileExists(lpszHeaderFile)))
    {
        // read the header file and save it to the top of the pot file
        std::wifstream inFile;
        inFile.imbue(std::locale(std::locale(), new utf8_conversion()));
        inFile.open(lpszHeaderFile, std::ios_base::binary);

        wchar_t ch;
        while(inFile && inFile.get(ch))
            File.put(ch);
        inFile.close();
    }
    else
    {
        File << L"# SOME DESCRIPTIVE TITLE.\n";
        File << L"# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER\n";
        File << L"# This file is distributed under the same license as the PACKAGE package.\n";
        File << L"# FIRST AUTHOR <[email protected]>, YEAR.\n";
        File << L"#\n";
        File << L"#, fuzzy\n";
        File << L"msgid \"\"\n";
        File << L"msgstr \"\"\n";
        File << L"\"Project-Id-Version: PACKAGE VERSION\\n\"\n";
        File << L"\"Report-Msgid-Bugs-To: \\n\"\n";
        File << L"\"POT-Creation-Date: 1900-01-01 00:00+0000\\n\"\n";
        File << L"\"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\\n\"\n";
        File << L"\"Last-Translator: FULL NAME <[email protected]>\\n\"\n";
        File << L"\"Language-Team: LANGUAGE <[email protected]>\\n\"\n";
        File << L"\"MIME-Version: 1.0\\n\"\n";
        File << L"\"Content-Type: text/plain; charset=UTF-8\\n\"\n";
        File << L"\"Content-Transfer-Encoding: 8bit\\n\"\n\n";
    }
    File << L"\n";
    File << L"# msgid/msgstr fields for Accelerator keys\n";
    File << L"# Format is: \"ID:xxxxxx:VACS+X\" where:\n";
    File << L"#    ID:xxxxx = the menu ID corresponding to the accelerator\n";
    File << L"#    V = Virtual key (or blank if not used) - nearly always set!\n";
    File << L"#    A = Alt key     (or blank if not used)\n";
    File << L"#    C = Ctrl key    (or blank if not used)\n";
    File << L"#    S = Shift key   (or blank if not used)\n";
    File << L"#    X = upper case character\n";
    File << L"# e.g. \"V CS+Q\" == Ctrl + Shift + 'Q'\n";
    File << L"\n";
    File << L"# ONLY Accelerator Keys with corresponding alphanumeric characters can be\n";
    File << L"# updated i.e. function keys (F2), special keys (Delete, HoMe) etc. will not.\n";
    File << L"\n";
    File << L"# ONLY change the msgstr field. Do NOT change any other.\n";
    File << L"# If you do not want to change an Accelerator Key, copy msgid to msgstr\n";
    File << L"\n";

    for (std::map<std::wstring, RESOURCEENTRY>::iterator I = this->begin(); I != this->end(); ++I)
    {
        std::wstring s = I->first;
        s.erase(s.begin(), std::find_if(s.begin(), s.end(), std::not1(std::ptr_fun<wint_t, int>(iswspace))));
        if (s.empty())
            continue;

        RESOURCEENTRY entry = I->second;
        for (std::vector<std::wstring>::iterator II = entry.automaticcomments.begin(); II != entry.automaticcomments.end(); ++II)
        {
            File << II->c_str() << L"\n";
        }
        for (std::vector<std::wstring>::iterator II = entry.translatorcomments.begin(); II != entry.translatorcomments.end(); ++II)
        {
            File << II->c_str() << L"\n";
        }
        if (!I->second.resourceIDs.empty())
        {
            File << L"#. Resource IDs: (";

            std::set<INT_PTR>::const_iterator II = I->second.resourceIDs.begin();
            File << (*II);
            ++II;
            while (II != I->second.resourceIDs.end())
            {
                File << L", ";
                File << (*II);
                ++II;
            };
            File << L")\n";
        }
        if (I->second.flag.length() > 0)
            File << (I->second.flag.c_str()) << L"\n";
        File << (L"msgid \"") << (I->first.c_str()) << L"\"\n";
        File << (L"msgstr \"") << (I->second.msgstr.c_str()) << L"\"\n\n";
        nEntries++;
    }
//.........这里部分代码省略.........
开发者ID:yuexiaoyun,项目名称:tortoisesvn,代码行数:101,代码来源:POFile.cpp

示例6: CStatusCacheEntry

CStatusCacheEntry CCachedDirectory::GetStatusFromCache(const CTGitPath& path, bool bRecursive)
{
	if(path.IsDirectory())
	{
		// We don't have directory status in our cache
		// Ask the directory if it knows its own status
		CCachedDirectory * dirEntry = CGitStatusCache::Instance().GetDirectoryCacheEntry(path);
		if( dirEntry)
		{
			if (dirEntry->IsOwnStatusValid())
				return dirEntry->GetOwnStatus(bRecursive);
			else
			{
				/* cache have outof date, need crawl again*/

				/*AutoLocker lock(dirEntry->m_critSec);
				ChildDirStatus::const_iterator it;
				for(it = dirEntry->m_childDirectories.begin(); it != dirEntry->m_childDirectories.end(); ++it)
				{
					CGitStatusCache::Instance().AddFolderForCrawling(it->first);
				}*/

				CGitStatusCache::Instance().AddFolderForCrawling(path);

				/*Return old status during crawling*/
				return dirEntry->GetOwnStatus(bRecursive);
			}
		}
		else
		{
			CGitStatusCache::Instance().AddFolderForCrawling(path);
		}
		return CStatusCacheEntry();
	}
	else
	{
		//All file ignored if under ignore directory
		if (m_ownStatus.GetEffectiveStatus() == git_wc_status_ignored)
			return CStatusCacheEntry(git_wc_status_ignored);
		if (m_ownStatus.GetEffectiveStatus() == git_wc_status_unversioned)
			return CStatusCacheEntry(git_wc_status_unversioned);

		// Look up a file in our own cache
		AutoLocker lock(m_critSec);
		CString strCacheKey = GetCacheKey(path);
		CacheEntryMap::iterator itMap = m_entryCache.find(strCacheKey);
		if(itMap != m_entryCache.end())
		{
			// We've hit the cache - check for timeout
			if(!itMap->second.HasExpired((long)GetTickCount()))
			{
				if(itMap->second.DoesFileTimeMatch(path.GetLastWriteTime()))
				{
					if ((itMap->second.GetEffectiveStatus()!=git_wc_status_missing)||(!PathFileExists(path.GetWinPath())))
					{
						// Note: the filetime matches after a modified has been committed too.
						// So in that case, we would return a wrong status (e.g. 'modified' instead
						// of 'normal') here.
						return itMap->second;
					}
				}
			}
		}

		CGitStatusCache::Instance().AddFolderForCrawling(path.GetContainingDirectory());
		return CStatusCacheEntry();
	}

}
开发者ID:hope2k,项目名称:TortoiseGit,代码行数:69,代码来源:CachedDirectory.cpp

示例7: CString

CBrowseFolder::retVal CBrowseFolder::Show(HWND parent, CString& path, const CString& sDefaultPath /* = CString() */)
{
    retVal ret = OK;		//assume OK
    m_sDefaultPath = sDefaultPath;
    if (m_sDefaultPath.IsEmpty() && !path.IsEmpty()) {
        while (!PathFileExists(path) && !path.IsEmpty()) {
            CString p = path.Left(path.ReverseFind(L'\\'));
            if ((p.GetLength() == 2) && (p[1] == L':')) {
                p += L"\\";
                if (p.Compare(path) == 0)
                    p.Empty();
            }
            if (p.GetLength() < 2)
                p.Empty();
            path = p;
        }
        // if the result path already contains a path, use that as the default path
        m_sDefaultPath = path;
    }

    HRESULT hr;

    // Create a new common open file dialog
    IFileOpenDialog* pfd = NULL;
    hr = CoCreateInstance(CLSID_FileOpenDialog, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pfd));
    if (SUCCEEDED(hr)) {
        // Set the dialog as a folder picker
        DWORD dwOptions;
        if (SUCCEEDED(hr = pfd->GetOptions(&dwOptions))) {
            hr = pfd->SetOptions(dwOptions | FOS_PICKFOLDERS | FOS_FORCEFILESYSTEM | FOS_PATHMUSTEXIST);
        }

        // Set a title
        if (SUCCEEDED(hr)) {
            TCHAR * nl = _tcschr(m_title, '\n');
            if (nl)
                *nl = 0;
            pfd->SetTitle(m_title);
        }

        // set the default folder
        if (SUCCEEDED(hr)) {
            typedef HRESULT(WINAPI *SHCIFPN)(PCWSTR pszPath, IBindCtx * pbc, REFIID riid, void ** ppv);

            SHCIFPN pSHCIFPN = hLib.GetProcAddress<SHCIFPN>("SHCreateItemFromParsingName");
            if (pSHCIFPN) {
                IShellItem *psiDefault = 0;
                hr = pSHCIFPN(m_sDefaultPath, NULL, IID_PPV_ARGS(&psiDefault));
                if (SUCCEEDED(hr)) {
                    hr = pfd->SetFolder(psiDefault);
                    psiDefault->Release();
                }
            }

        }

        // Show the open file dialog
        if (SUCCEEDED(hr) && SUCCEEDED(hr = pfd->Show(parent))) {
            // Get the selection from the user
            IShellItem* psiResult = NULL;
            hr = pfd->GetResult(&psiResult);
            if (SUCCEEDED(hr)) {
                PWSTR pszPath = NULL;
                hr = psiResult->GetDisplayName(SIGDN_FILESYSPATH, &pszPath);
                if (SUCCEEDED(hr)) {
                    path = pszPath;
                    CoTaskMemFree(pszPath);
                }
                psiResult->Release();
            } else
                ret = CANCEL;
        } else
            ret = CANCEL;

        pfd->Release();
    } else {
        BROWSEINFO browseInfo = {};
        browseInfo.hwndOwner = parent;
        browseInfo.pidlRoot = m_root;
        browseInfo.pszDisplayName = m_displayName;
        browseInfo.lpszTitle = m_title;
        browseInfo.ulFlags = m_style;
        browseInfo.lParam = reinterpret_cast<LPARAM>(this);

        PCIDLIST_ABSOLUTE itemIDList = SHBrowseForFolder(&browseInfo);

        //is the dialog canceled?
        if (!itemIDList)
            ret = CANCEL;

        if (ret != CANCEL) {
            if (!SHGetPathFromIDList(itemIDList, path.GetBuffer(MAX_PATH)))		// MAX_PATH ok. Explorer can't handle paths longer than MAX_PATH.
                ret = NOPATH;

            path.ReleaseBuffer();

            CoTaskMemFree((LPVOID)itemIDList);
        }
    }

//.........这里部分代码省略.........
开发者ID:zenden2k,项目名称:FileSearch,代码行数:101,代码来源:BrowseFolder.cpp

示例8: HasStashDir

bool CTGitPath::HasStashDir() const
{
	CString topdir;
	if(!GitAdminDir::HasAdminDir(GetWinPathString(),&topdir))
	{
		return false;
	}

	CString dotGitPath;
	GitAdminDir::GetAdminDirPath(topdir, dotGitPath);

	if (!!PathFileExists(dotGitPath + _T("refs\\stash")))
		return true;

	CAutoFile hfile = CreateFile(dotGitPath + _T("packed-refs"), GENERIC_READ, 
		FILE_SHARE_READ | FILE_SHARE_DELETE | FILE_SHARE_WRITE, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
	if (!hfile)
		return false;

	DWORD filesize = ::GetFileSize(hfile, nullptr);
	if (filesize == 0)
		return false;

	DWORD size = 0;
	auto buff = std::make_unique<char[]>(filesize + 1);
	ReadFile(hfile, buff.get(), filesize, &size, nullptr);
	buff.get()[filesize] = '\0';

	if (size != filesize)
		return false;

	for (DWORD i = 0; i < filesize;)
	{
		if (buff[i] == '#' || buff[i] == '^')
		{
			while (buff[i] != '\n')
			{
				++i;
				if (i == filesize)
					break;
			}
			++i;
		}

		if (i >= filesize)
			break;

		while (buff[i] != ' ')
		{
			++i;
			if (i == filesize)
				break;
		}

		++i;
		if (i >= filesize)
			break;

		if (i <= filesize - 10 && (buff[i + 10] == '\n' || buff[i + 10] == '\0') && !strncmp("refs/stash", buff.get() + i, 10))
			return true;
		while (buff[i] != '\n')
		{
			++i;
			if (i == filesize)
				break;
		}

		while (buff[i] == '\n')
		{
			++i;
			if (i == filesize)
				break;
		}
	}
	return false;
}
开发者ID:iamduyu,项目名称:TortoiseGit,代码行数:76,代码来源:TGitPath.cpp

示例9: ExeCmd

//.........这里部分代码省略.........
		}
		return FALSE;
	}

	char FilePath[255];
	memset(FilePath, 0, sizeof(FilePath));
	sprintf(FilePath, "%s\\SmtRec.dat", m_EnvPath);

	FILE *fp = fopen(FilePath, "r");
	if(NULL == fp){
		return FALSE;
	}

	fseek(fp, 0, SEEK_END);
	long fileLength = ftell(fp);
	int CycleTimes = (int)fileLength/255 - 1;
	fseek(fp, 255, SEEK_SET);

	m_RecFileLen = fileLength;

	char RecPath[255];
	char TmpPath[255];

	m_InCtrCount = 0;
	memset(m_InCtrNo, 0, sizeof(m_InCtrNo));

	BOOL TFlag = FALSE;

	for(int i = 0; i < m_NumFiles; i++){
		int PathLen = strlen(m_szFile[i]);
		int k = 0;
		for(k = 0; k < CycleTimes; k++){
			memset(RecPath, 0, sizeof(RecPath));
			memset(TmpPath, 0, sizeof(TmpPath));
			fread(RecPath, 1, sizeof(RecPath), fp);
			sprintf(TmpPath, "%s%s", m_EnvPath, RecPath);
			if((PathLen == strlen(TmpPath)) && (!memcmp(m_szFile[i], TmpPath, PathLen))){
				break;
			}
		}
		if(k < CycleTimes){
			m_InCtrNo[m_InCtrCount] = i;
			m_InCtrCount++;
			TFlag = TRUE;
			/*if(!m_AddFlag){
				if(FILE_ATTRIBUTE_DIRECTORY != GetFileAttributes(m_szFile[i])){
					string StatusStr;
					string StatusCmd = "svn status ";
					StatusCmd += "\"";
					StatusCmd += m_szFile[i];
					StatusCmd += "\"";
					StatusStr += ExeCmd((char *)StatusCmd.c_str());
					if(StatusStr.npos != StatusStr.find("A       ")){
						m_AddFlag = TRUE;
					}
				}
			}*/
		}
		else{
			string StatusStr;
			string StatusCmd = "svn status ";
			StatusCmd += "\"";
			StatusCmd += m_szFile[i];
			StatusCmd += "\"";
			StatusStr += ExeCmd((char *)StatusCmd.c_str());
			if(0 == StatusStr.find("A       ")){
				m_InCtrNo[m_InCtrCount] = i;
				m_InCtrCount++;
				TFlag = TRUE;
				m_AddFlag = TRUE;
			}
		}
		fseek(fp, 255, SEEK_SET);
	}

	fclose(fp);

	if(TFlag){
		return TRUE;
	}

	for(int i = 0; i < m_NumFiles; i++){
		if((!strcmp(m_EnvPath, m_szFile[i])) && m_RecFileLen > 255){
			return TRUE;
		}
	}

	if(1 == m_NumFiles){
		if(!strcmp(m_EnvPath, m_szFile[0])){
			char SvnPath[255];
			memset(SvnPath, 0, sizeof(SvnPath));
			sprintf(SvnPath, "%s\\.svn", m_EnvPath);
			if(PathFileExists(SvnPath)){
				return TRUE;
			}
		}
	}
	
	return FALSE;
}
开发者ID:songcser,项目名称:ALM,代码行数:101,代码来源:SmtShell.cpp

示例10: PathFileExists

int CDAO::IsDBFileExist()
{
	int bIsExist = PathFileExists(GetInstallFilePath("BussinessLog.accdb"));
	return bIsExist;
}
开发者ID:lsi3131,项目名称:test,代码行数:5,代码来源:DAO.cpp

示例11: Execute

int Title::Execute()
{
	if (!bSequenceChangeng){

		//上下の項目選択
		//上
		if (CheckStateKey(KEY_INPUT_UP) == 1 || (CheckStateKey(KEY_INPUT_UP) > 15 && CheckStateKey(KEY_INPUT_UP) % 10 == 0)){
			
			//移動先がLoadなら
			if (Selecting == TIT_EXIT){
				//セーブファイルが有れば
				if (PathFileExists("savedata.sav")){
					Selecting = (Selecting + 2) % 3;
				}
				//なければ飛ばす
				else  Selecting = TIT_START;
			}
			else Selecting = (Selecting + 2) % 3;
			
			return MAIN_SEQ_CONTINUE;
		}
		if (CheckStateKey(KEY_INPUT_DOWN) == 1 || (CheckStateKey(KEY_INPUT_DOWN) > 15 && CheckStateKey(KEY_INPUT_DOWN) % 10 == 0)){
			
			//移動先がLoadなら
			if (Selecting == TIT_START){
				//セーブファイルが有れば
				if (PathFileExists("savedata.sav")){
					Selecting = (Selecting + 1) % 3;
				}
				//なければ飛ばす
				else  Selecting = TIT_EXIT;
			}
			else Selecting = (Selecting + 1) % 3;
			
		
			return MAIN_SEQ_CONTINUE;
		}
		//決定キー
		if (CheckStateKey(KEY_INPUT_Z) == 1){
			bSequenceChangeng = true;

			return MAIN_SEQ_CONTINUE;
		}

	}
	else {
		++ChangeCounter;
		
		if (ChangeCounter == ChangeFrame){
			
			switch (Selecting){
			case TIT_START:
				return MAIN_SEQ_PROLOGUE;
				break;


			case TIT_LOAD:
				return MAIN_SEQ_GAMEMAIN;
				break;

			//終了
			case TIT_EXIT:
				return MAIN_SEQ_EXIT;
				break;

			default:
				MessageBox(NULL, "不正なシーケンスが返されました。", "error", MB_OK);
				break;
			}
		}

	}
	MainCounter++;

	return MAIN_SEQ_CONTINUE;
}
开发者ID:kyouma0220,项目名称:RogueLike2014,代码行数:76,代码来源:Title.cpp

示例12: uploadFile

// Uploads the PNG file to Gyazo
BOOL uploadFile(HWND hwnd, LPCTSTR fileName, BOOL isPng)
{
	const int nSize = 256;
	LPCTSTR DEFAULT_UPLOAD_SERVER = _T("upload.gyazo.com");
	LPCTSTR DEFAULT_UPLOAD_PATH   = _T("/upload.cgi");
	LPCTSTR DEFAULT_UPLOAD_TOKEN = _T("");
	//LPCTSTR DEFAULT_USER_AGENT    = _T("User-Agent: Gyazowin/1.0\r\n");
	const int DEFAULT_UPLOAD_SERVER_PORT = INTERNET_DEFAULT_HTTP_PORT;

	TCHAR upload_server[nSize];
	TCHAR upload_path[nSize];
	TCHAR upload_token[nSize];
	//TCHAR ua[nSize];
	lstrcpy(upload_server, DEFAULT_UPLOAD_SERVER);
	lstrcpy(upload_path, DEFAULT_UPLOAD_PATH);
	lstrcpy(upload_token, DEFAULT_UPLOAD_TOKEN);
	//lstrcpy(ua, DEFAULT_USER_AGENT);
	int upload_server_port = DEFAULT_UPLOAD_SERVER_PORT;

	TCHAR runtime_path[MAX_PATH+1];
	TCHAR runtime_dirname[MAX_PATH+1];
	TCHAR config_file[MAX_PATH+1];
	if (0 != ::GetModuleFileName(NULL, runtime_path, MAX_PATH)) {
		TCHAR tmp[MAX_PATH+1];
		_tsplitpath_s(runtime_path, tmp, runtime_dirname, tmp, tmp);
	}
	lstrcpy(config_file, runtime_dirname);
	lstrcat(config_file, _T("\\gyazo.ini"));
	if (PathFileExists(config_file)) {
		LPCTSTR SECTION_NAME = _T("gyazo");
		GetPrivateProfileString(SECTION_NAME, _T("server"), DEFAULT_UPLOAD_SERVER, upload_server, sizeof(upload_server), config_file);
		GetPrivateProfileString(SECTION_NAME, _T("path"), DEFAULT_UPLOAD_PATH, upload_path, sizeof(upload_path), config_file);
		GetPrivateProfileString(SECTION_NAME, _T("token"), DEFAULT_UPLOAD_TOKEN, upload_token, sizeof(upload_token), config_file);
		//GetPrivateProfileString(SECTION_NAME, _T("user_agent"), DEFAULT_USER_AGENT, ua, sizeof(ua), config_file);
		upload_server_port = GetPrivateProfileInt(SECTION_NAME, _T("port"), DEFAULT_UPLOAD_SERVER_PORT, config_file);
	}

	const char*  sBoundary = "----BOUNDARYBOUNDARY----";		// boundary
	const char   sCrLf[]   = { 0xd, 0xa, 0x0 };					// 改行(CR+LF)
	TCHAR szHeader[200];

	StringCchPrintf(szHeader, 200, TEXT("Auth-Token: %s\r\nContent-type: multipart/form-data; boundary=----BOUNDARYBOUNDARY----"), upload_token);

	std::ostringstream	buf;	// 送信メッセージ

	wchar_t fname[_MAX_FNAME];
	wchar_t ext[_MAX_EXT];
	_wsplitpath(fileName, NULL, NULL, fname, ext );
	std::string data = (isPng) ? "imagedata" : "data";
	LPCTSTR file = (isPng) ? _T("gyazo") : wcsncat(fname, ext, _MAX_FNAME);
	size_t size = wcstombs(NULL, file, 0);
	char* CharStr = new char[size + 1];
	wcstombs(CharStr, file, size + 1);

	// -- "imagedata" part
	buf << "--";
	buf << sBoundary;
	buf << sCrLf;
	buf << "content-disposition: form-data; name=\"";
	buf << data;
	buf << "\"; filename=\"";
	buf << CharStr;
	buf << "\"";
	buf << sCrLf;
	//buf << "Content-type: image/png";	// 一応
	//buf << sCrLf;
	buf << sCrLf;

	// 本文: PNG ファイルを読み込む
	std::ifstream png;
	png.open(fileName, std::ios::binary);
	if (png.fail()) {
		MessageBox(hwnd, _T("PNG open failed"), szTitle, MB_ICONERROR | MB_OK);
		png.close();
		return FALSE;
	}
	buf << png.rdbuf();		// read all & append to buffer
	png.close();

	// 最後
	buf << sCrLf;
	buf << "--";
	buf << sBoundary;
	buf << "--";
	buf << sCrLf;

	// メッセージ完成
	std::string oMsg(buf.str());

	// WinInet を準備 (proxy は 規定の設定を利用)
	HINTERNET hSession    = InternetOpen(_T("Gyazowin/1.0"), 
		INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
	if(NULL == hSession) {
		LastErrorMessageBox(hwnd, _T("Cannot configure wininet."));
		return FALSE;
	}
	
	// 接続先
	HINTERNET hConnection = InternetConnect(hSession, 
//.........这里部分代码省略.........
开发者ID:zzeneg,项目名称:Gyazowin,代码行数:101,代码来源:gyazowin.cpp

示例13: switch

void CDialogResultNodeOri::OnBnClickedButtonNodeorihangquery()
{
	CLineComputeView* pView = (CLineComputeView*)((CMainFrame *)AfxGetMainWnd())->GetActiveView(); 
	int span = m_resultSpan.GetCurSel() + 1;
	int hang = m_spanLeftRight.GetCurSel();
	float x=0, y=0, z=0, x0=0, y0=0, z0=0;
	int spanRight;
	CString fileName1, fileName2, fileName3, strTmp, line;
	CStdioFile file;
	switch (pView->m_data->m_windType)
	{
	case 0:default:
		fileName1 = fileName2 = fileName3 = _T("jf");
		break;
	case 1:
		fileName1 = fileName2 = fileName3 = _T("zf");
		break;
	case 2:
		fileName1 = fileName2 = fileName3 = _T("mdf");
		break;
	}
	/*提取挂点张力*/
	fileName1 += _T("_span");
	strTmp.Format(_T("%d"), span);
	fileName1 += strTmp;
	strTmp = 0==hang? _T("_l_"): _T("_r_");
	fileName1 += strTmp;
	fileName1 += _T("hang_force.dat");
	CString path1 = pView->m_data->m_workspace + _T("\\result\\") + fileName1;
	if(!PathFileExists(path1))
	{
		MessageBox(_T("结果文件") + path1 + _T("不存在!"), MsgCaption);
		return ;
	}
	file.Open(path1, CStdioFile::modeRead);
	while(file.ReadString(strTmp))
	{
		if(strTmp.GetLength()>0) line = strTmp;
	}
	file.Close();
	//挂点力须乘以导线分裂数
	float hangForce = abs(_ttof(line.Mid(15, 15).TrimLeft()))*pView->m_data->m_dxSplitNum;
	strTmp.Format(_T("%.5f"), hangForce);
	m_nodeForce.SetWindowText(strTmp);
	/*提取挂点不平衡张力及挂点坐标*/
	if((pView->m_data->m_dxSpanNum==span&&1==hang) || (1==span&&0==hang)){ //第一跨左挂点或最后一跨右挂点
		m_nodeUnbalancedForce.SetWindowText(_T("该挂点无不平衡张力"));
		if(1==span&&0==hang)
		{
			x0 = y0 = 0;
		}
		if(pView->m_data->m_dxSpanNum==span&&1==hang)
		{
			for(int k=0; k<pView->m_data->m_dxSpanNum; k++)
			{
				x0 += pView->m_data->m_dxDjgc[k].dj;
				y0 += pView->m_data->m_dxDjgc[k].gc;
			}
		}
	}
	else
	{
		fileName2 += _T("_span");
		fileName3 += _T("_span");
		if(0 == hang) //左挂点
		{
			strTmp.Format(_T("%d_%d_"), span-1, span);
			spanRight = span-1;
		}
		else //右挂点
		{
			strTmp.Format(_T("%d_%d_"), span, span+1);
			spanRight = span;
		}
		fileName2 += strTmp + _T("unbalanced_force.dat");
		fileName3 += strTmp + _T("hang_ori.dat");
		CString path2 = pView->m_data->m_workspace + _T("\\result\\") + fileName2;
		if(!PathFileExists(path2))
		{
			MessageBox(_T("结果文件") + path2 + _T("不存在!"), MsgCaption);
			return ;
		}
		file.Open(path2, CStdioFile::modeRead);
		while(file.ReadString(strTmp))
		{
			if(strTmp.GetLength()>0) line = strTmp;
		}
		file.Close();
		//挂点不平衡张力需乘以绝缘子串数
		float unBalanceForce = _ttof(line.Mid(15, 15).TrimLeft())*pView->m_data->m_jyzStringNum;
		strTmp.Format(_T("%.5f"), unBalanceForce);
		m_nodeUnbalancedForce.SetWindowText(strTmp);
		CString path3 = pView->m_data->m_workspace + _T("\\result\\") + fileName3;
		if(!PathFileExists(path3))
		{
			MessageBox(_T("结果文件") + path3 + _T("不存在!"), MsgCaption);
			return ;
		}
		file.Open(path3, CStdioFile::modeRead);
		while(file.ReadString(strTmp))
//.........这里部分代码省略.........
开发者ID:yanchenghust,项目名称:transferLine,代码行数:101,代码来源:DialogResultNodeOri.cpp

示例14: getBufferByID

bool FileManager::saveBuffer(BufferID id, const TCHAR * filename, bool isCopy) {
	Buffer * buffer = getBufferByID(id);
	bool isHidden = false;
	bool isSys = false;
	DWORD attrib = 0;

	TCHAR fullpath[MAX_PATH];
	::GetFullPathName(filename, MAX_PATH, fullpath, NULL);
	::GetLongPathName(fullpath, fullpath, MAX_PATH);
	if (PathFileExists(fullpath))
	{
		attrib = ::GetFileAttributes(fullpath);

		if (attrib != INVALID_FILE_ATTRIBUTES)
		{
			isHidden = (attrib & FILE_ATTRIBUTE_HIDDEN) != 0;
			if (isHidden)
				::SetFileAttributes(filename, attrib & ~FILE_ATTRIBUTE_HIDDEN);

			isSys = (attrib & FILE_ATTRIBUTE_SYSTEM) != 0;
			if (isSys)
				::SetFileAttributes(filename, attrib & ~FILE_ATTRIBUTE_SYSTEM);
		}
	}

	UniMode mode = buffer->getUnicodeMode();
	if (mode == uniCookie)
		mode = uni8Bit;	//set the mode to ANSI to prevent converter from adding BOM and performing conversions, Scintilla's data can be copied directly

	Utf8_16_Write UnicodeConvertor;
	UnicodeConvertor.setEncoding(mode);

	int encoding = buffer->getEncoding();

	FILE *fp = UnicodeConvertor.fopen(fullpath, TEXT("wb"));
	if (fp)
	{
		_pscratchTilla->execute(SCI_SETDOCPOINTER, 0, buffer->_doc);	//generate new document

		int lengthDoc = _pscratchTilla->getCurrentDocLen();
		char* buf = (char*)_pscratchTilla->execute(SCI_GETCHARACTERPOINTER);	//to get characters directly from Scintilla buffer
		if (encoding == -1) //no special encoding; can be handled directly by Utf8_16_Write
		{
			UnicodeConvertor.fwrite(buf, lengthDoc);
		}
		else
		{
			WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance();
			int grabSize;
			for (int i = 0; i < lengthDoc; i += grabSize)
			{
				grabSize = lengthDoc - i;
				if (grabSize > blockSize) 
					grabSize = blockSize;
				
				int newDataLen = 0;
				int incompleteMultibyteChar = 0;
				const char *newData = wmc->encode(SC_CP_UTF8, encoding, buf+i, grabSize, &newDataLen, &incompleteMultibyteChar);
				grabSize -= incompleteMultibyteChar;
				UnicodeConvertor.fwrite(newData, newDataLen);
			}
		}
		UnicodeConvertor.fclose();

		if (isHidden)
			::SetFileAttributes(fullpath, attrib | FILE_ATTRIBUTE_HIDDEN);

		if (isSys)
			::SetFileAttributes(fullpath, attrib | FILE_ATTRIBUTE_SYSTEM);

		if (isCopy) {
			_pscratchTilla->execute(SCI_SETDOCPOINTER, 0, _scratchDocDefault);
			return true;	//all done
		}

		buffer->setFileName(fullpath);
		buffer->setDirty(false);
		buffer->setStatus(DOC_REGULAR);
		buffer->checkFileState();
		_pscratchTilla->execute(SCI_SETSAVEPOINT);
		//_pscratchTilla->markSavedLines();
		_pscratchTilla->execute(SCI_SETDOCPOINTER, 0, _scratchDocDefault);

		return true;
	}
	return false;
}
开发者ID:Tanjas5,项目名称:npp,代码行数:87,代码来源:Buffer.cpp

示例15: UpdateData

void COpenDlg::OnOK()
{
	UpdateData(TRUE);

	bool bUDiffOnClipboard = false;
	if (OpenClipboard())
	{
		UINT enumFormat = 0;
		do
		{
			if (enumFormat == m_cFormat)
			{
				bUDiffOnClipboard = true;
			}
		} while((enumFormat = EnumClipboardFormats(enumFormat))!=0);
		CloseClipboard();
	}

	if (GetDlgItem(IDC_BASEFILEEDIT)->IsWindowEnabled())
	{
		m_sUnifiedDiffFile.Empty();
		m_sPatchDirectory.Empty();
	}
	else
	{
		m_sBaseFile.Empty();
		m_sYourFile.Empty();
		m_sTheirFile.Empty();
	}
	UpdateData(FALSE);
	CString sFile;
	if (!m_sUnifiedDiffFile.IsEmpty())
		if (!PathFileExists(m_sUnifiedDiffFile))
			sFile = m_sUnifiedDiffFile;
	if (!m_sPatchDirectory.IsEmpty())
		if (!PathFileExists(m_sPatchDirectory))
			sFile = m_sPatchDirectory;
	if (!m_sBaseFile.IsEmpty())
		if (!PathFileExists(m_sBaseFile))
			sFile = m_sBaseFile;
	if (!m_sYourFile.IsEmpty())
		if (!PathFileExists(m_sYourFile))
			sFile = m_sYourFile;
	if (!m_sTheirFile.IsEmpty())
		if (!PathFileExists(m_sTheirFile))
			sFile = m_sTheirFile;

	if (bUDiffOnClipboard && m_bFromClipboard)
	{
		if (OpenClipboard())
		{
			HGLOBAL hglb = GetClipboardData(m_cFormat);
			LPCSTR lpstr = (LPCSTR)GlobalLock(hglb);

			DWORD len = GetTempPath(0, nullptr);
			auto path = std::make_unique<TCHAR[]>(len + 1);
			auto tempF = std::make_unique<TCHAR[]>(len + 100);
			GetTempPath (len+1, path.get());
			GetTempFileName(path.get(), L"tsm", 0, tempF.get());
			CString sTempFile = CString(tempF.get());

			FILE * outFile;
			size_t patchlen = strlen(lpstr);
			_wfopen_s(&outFile, sTempFile, L"wb");
			if(outFile)
			{
				size_t size = fwrite(lpstr, sizeof(char), patchlen, outFile);
				if (size < patchlen)
					bUDiffOnClipboard = false;
				else
				{
					m_sUnifiedDiffFile = sTempFile;
					UpdateData(FALSE);
					sFile.Empty();
				}
				fclose(outFile);
			}
			GlobalUnlock(hglb);
			CloseClipboard();
		}

	}

	if (!sFile.IsEmpty())
	{
		CString sErr;
		sErr.Format(IDS_ERR_PATCH_INVALIDPATCHFILE, (LPCTSTR)sFile);
		MessageBox(sErr, nullptr, MB_ICONERROR);
		return;
	}
	CRegDWORD lastRadioButton(L"Software\\TortoiseGitMerge\\OpenRadio", IDC_MERGERADIO);
	lastRadioButton = GetCheckedRadioButton(IDC_MERGERADIO, IDC_APPLYRADIO);
	CStandAloneDialog::OnOK();
}
开发者ID:YueLinHo,项目名称:TortoiseGit,代码行数:94,代码来源:OpenDlg.cpp

本文标签属性:

示例:示例图

代码:代码生成器

PathFileExists:PathFileExists

上一篇:PHP FileFactory::__construct方法代码示例
下一篇:导演为什么能自导自演?(自导自演的意思是什么)

为您推荐