Created
September 22, 2012 16:30
-
-
Save julp/3766677 to your computer and use it in GitHub Desktop.
Réécriture de SystemTools::FileIsFullPath
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
########## Private ########## | |
# From Source/cmInstallGenerator.cxx: | |
# std::string cmInstallGenerator::GetInstallDestination() const | |
# { | |
# std::string result; | |
# | |
# if(!this->Destination.empty() && !cmSystemTools::FileIsFullPath(this->Destination.c_str())) { | |
# result = "${CMAKE_INSTALL_PREFIX}/"; | |
# } | |
# result += this->Destination; | |
# return result; | |
# } | |
# From Source/kwsys/SystemTools.cxx: | |
# bool SystemTools::FileIsFullPath(const char* in_name) | |
# { | |
# kwsys_stl::string name = in_name; | |
# #if defined(_WIN32) || defined(__CYGWIN__) | |
# // On Windows, the name must be at least two characters long. | |
# if(name.length() < 2) { | |
# return false; | |
# } | |
# if(name[1] == ':') { | |
# return true; | |
# } | |
# if(name[0] == '\\') { | |
# return true; | |
# } | |
# #else | |
# // On UNIX, the name must be at least one character long. | |
# if(name.length() < 1) { | |
# return false; | |
# } | |
# #endif | |
# #if !defined(_WIN32) | |
# if(name[0] == '~') { | |
# return true; | |
# } | |
# #endif | |
# // On UNIX, the name must begin in a '/'. | |
# // On Windows, if the name begins in a '/', then it is a full | |
# // network path. | |
# if(name[0] == '/') { | |
# return true; | |
# } | |
# return false; | |
# } | |
function(is_full_path _path _outvar) | |
string(LENGTH ${_path} PATH_LEN) | |
string(SUBSTRING ${_path} 0 1 FIRST_CHAR) | |
string(SUBSTRING ${_path} 1 1 SECOND_CHAR) | |
if(WIN32 OR CYGWIN) | |
if(PATH_LEN LESS 2) | |
set(${_outvar} FALSE PARENT_SCOPE) | |
return() | |
endif(PATH_LEN LESS 2) | |
if(SECOND_CHAR STREQUAL ":") | |
set(${_outvar} TRUE PARENT_SCOPE) | |
return() | |
endif(FIRST_CHAR STREQUAL ":") | |
if(FIRST_CHAR STREQUAL "\\") | |
set(${_outvar} TRUE PARENT_SCOPE) | |
return() | |
endif(FIRST_CHAR STREQUAL "\\") | |
else(WIN32 OR CYGWIN) | |
if(PATH_LEN LESS 1) | |
set(${_outvar} FALSE PARENT_SCOPE) | |
return() | |
endif(PATH_LEN LESS 1) | |
endif(WIN32 OR CYGWIN) | |
if(NOT WIN32) | |
if(FIRST_CHAR STREQUAL "~") | |
set(${_outvar} TRUE PARENT_SCOPE) | |
return() | |
endif(FIRST_CHAR STREQUAL "~") | |
endif(NOT WIN32) | |
if(FIRST_CHAR STREQUAL "/") | |
set(${_outvar} TRUE PARENT_SCOPE) | |
return() | |
endif(FIRST_CHAR STREQUAL "/") | |
set(${_outvar} FALSE PARENT_SCOPE) | |
endfunction(is_full_path) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment