본문 바로가기
C++ 200제/코딩 IT 정보

[MFC강좌] 폴더 파일 경로 5. PathSkipRoot 등 16개 함수

by vicddory 2017. 11. 17.

[MFC강좌] 폴더 파일 경로 5. PathSkipRoot 등 16개 함수


void PathSetDlgItemPath( HWND hDlg, int id, LPCSTR pszPath );

PathCompactPath와 유사하다. id로 지정된 Dialog Item에 출력하기 적합한 길이로 경로를 잘라준다.


LPCTSTR PathSkipRoot( LPCTSTR pszPath );

루트 경로를 제거한다.

로컬 경로인 경우 드라이브문자(c:\)가 지워지고, UNC 경로인 경우 서버 이름, 공유 폴더 이름이 제거된다.


PathSkipRoot( "c:\temp\test.txt") = temp\test.txt

PathSkipRoot( "\\server\c$\temp\test.txt") = temp\test.txt


void PathStripPath( LPTSTR pszPath );

전체 경로에서 파일 이름(또는 마지막 폴더 이름)만을 남기고 제거한다.


PathStripPath("c:\temp\test.txt") = test.txt

PathStripPath("c:\temp\foo") = foo

BOOL PathStripToRoot( LPTSTR szRoot );

루트경로만 남기고 나머지를 제거한다.


PathStripToRoot("c:\temp") = c:\


BOOL PathUnExpandEnvStrings( LPCTSTR pszPath, LPTSTR pszBuf, UINT cchBuf );

경로와 일치하는 환경변수로 치환해 준다.


char szBuffer[MAX_PATH];

PathUnExpandEnvStrings( "c:\windows\", szBuffer, MAX_PATH ) = "%SystemRoot%";


MFC 강좌 폴더 경로[[MFC강좌] 폴더 파일 경로 5. PathSkipRoot 등 16개 함수]


BOOL PathUnmakeSystemFolder( LPTSTR pszPath );

폴더속성에서 system 속성을 제거한다.


void PathUnquoteSpaces( LPTSTR lpsz );

경로를 둘러싼 큰 따옴표(")를 제거해 준다.


PathUnquoteSpaces("\"c:\temp\"") = c:\temp


HRESULT UrlApplyScheme(LPCTSTR pszIn, LPTSTR pszOut, LPDWORD pcchOut, DWORD dwFlags );

경로앞에 적절한 scheme를 붙여준다. (http://, file:///, ftp:// 등)


HRESULT UrlCanonicalize( LPCTSTR pszUrl, LPTSTR pszCanonicalized, LPDWORD pcchCanonicalized, DWORD dwFlags );

URL 경로에 포함된 상대경로( '.', '..')를 적절하게 처리한다.

dwFlag값에 따라 안전하지 않은 문자들을 escape 처리 하는 등의 기능도 수행할 수 있다.


MFC 강좌 파일 경로[[MFC강좌] 폴더 파일 경로 5. PathSkipRoot 등 16개 함수]


HRESULT UrlCombine(LPCTSTR pszBase, LPCTSTR pszRelative, LPTSTR pszCombined, LPDWORD pcchCombined, DWORD dwFlags );

두 URL 경로를 합쳐준다.


UrlCombine( "http://www.greenmaru.com/", "default.aspx", lpszCombine, &dwSize, 0 ) =


"http://www.greenmaru.com/default.aspx"


주의!

UrlCombine( "http://abc.com/a/b/c", "d" ...)는 "http://abc.com/a/b/d"가 된다.

UrlCombine( "http://abc.com/a/b/c/", "d" ...)로 해야 "http://abc.com/a/b/c/d"가 된다.


int UrlCompare( LPCTSTR pszURL1, LPCTSTR pszURL2, BOOL fIgnoreSlash );

두 URL 문자열을 비교한다. (대소문자 구분 없음)


HRESULT UrlCreateFromPath(LPCTSTR pszPath, LPTSTR pszUrl, LPDWORD pcchUrl, DWORD dwReserved );

로컬 경로 문자열(c:\temp)을 URL 포맷(file:///c:\temp)으로 변환해준다.


HRESULT UrlEscape(LPCTSTR pszURL, LPTSTR pszEscaped, LPDWORD pcchEscaped,DWORD dwFlags );

URL로 사용할 수 없는 문자들(^, {, " 등)을 URL encoding 된 문자열로 변환해 준다.


MFC 폴더 파일 경로[[MFC강좌] 폴더 파일 경로 5. PathSkipRoot 등 16개 함수]


HRESULT UrlEscapeSpaces( LPCTSTR pszURL, LPTSTR pszEscaped, LPDWORD pcchEscaped );

URL에 포함된 공백을 escapce처리 해 준다.


HRESULT UrlGetPart(LPCTSTR pszIn, LPTSTR pszOut, LPDWORD pcchOut, DWORD dwPart, DWORD dwFlags );

dwPart값에 따라 URL에서 특정부분을 분리해 준다. (hostname, port...)


BOOL UrlIs( LPCTSTR pszUrl, URLIS UrlIs );

URL이 UrlIs에 제시된 조건(적합한 URL인가? 파일 경로인가? 등)에 맞는 구성인지 확인한다.


[MFC강좌] 폴더 파일 경로 5. PathSkipRoot 등 16개 함수

댓글