본문으로 바로가기

https://likle.github.io/cwalk/

https://github.com/likle/cwalk

 

C/C++용으로 아주 괜찮은 절대 패스 <-> 상대 패스 상호 변환 라이브러리.. cwalk..

윈도우즈/리눅스 스타일도 지원..

 

아래와 같이 간단한 래퍼 함수를 만들어봄..

#include <limits.h> // FILENAME_MAX 
#include <cwalk.h>

std::string Rel2AbsPath(const std::string& base, const std::string& relative, bool unix_style) 
{
	if(unix_style)
		cwk_path_set_style(CWK_STYLE_UNIX);
	else
		cwk_path_set_style(CWK_STYLE_WINDOWS);

	char buffer[FILENAME_MAX];
	cwk_path_get_absolute(base.c_str(), relative.c_str(), buffer, sizeof(buffer));
	return std::string(buffer);
}

std::string Abs2RelPath(const std::string& base, const std::string& absolute, bool unix_style) 
{
	if(unix_style)
		cwk_path_set_style(CWK_STYLE_UNIX);
	else
		cwk_path_set_style(CWK_STYLE_WINDOWS);

	char buffer[FILENAME_MAX];
	cwk_path_get_relative(base.c_str(), absolute.c_str(), buffer, sizeof(buffer));
	return std::string(buffer);
}

cwalk-master.zip
0.11MB

'블로그 (Blog) > 개발로그 (Devlogs)' 카테고리의 다른 글

libcpr  (0) 2025.10.23
도스 폰트  (0) 2025.09.19
요소 절점 순서 (element node odering)  (0) 2025.09.08
ICU를 이용한 파일 인코딩 검출하기  (0) 2025.09.05
OpenLava 4.0  (0) 2025.09.05