📄 filepath.cpp
字号:
/***************************************************************************/
/* NOTE: */
/* This document is copyright (c) by Oz Solomon and Yonat Sharon, and is */
/* bound by the MIT open source license. */
/* See License.txt or visit www.opensource.org/licenses/mit-license.html */
/***************************************************************************/
#include "stdafx.h"
#include "FilePath.h"
#include <io.h>
CString GetFilePath(const CString& fileName)
{
// try in the application directory
TCHAR path[_MAX_PATH];
GetModuleFileName(AfxGetInstanceHandle(), path, _MAX_PATH);
for ( size_t end = _tcslen(path)-1;
end > 0 && path[end] != '\\';
--end )
;
_tcscpy(path+end+1, fileName);
if (_taccess(path, 0) == 0)
return path;
// try in Windows directory
TCHAR path2[_MAX_PATH];
_tcscpy(path2, _tgetenv("windir"));
size_t len = _tcslen(path2);
path2[len] = '\\';
_tcscpy(path2+len+1, fileName);
if (_taccess(path2, 0) == 0)
return path2;
FILE* f = fopen(path, "w+");
if (f) {
fflush(f);
fclose(f);
return path;
}
return "";
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -