MCPcopy Create free account
hub / github.com/LASzip/LASzip / HasFileExt

Function HasFileExt

src/mydefs.cpp:459–470  ·  view source on GitHub ↗

Check if file has a certain file extension (case insensitive) filename extension, like ".laz" or "laz" TRUE if filename has the given extension

Source from the content-addressed store, hash-verified

457/// <param name="ext">extension, like ".laz" or "laz"</param>
458/// <returns>TRUE if filename has the given extension</returns>
459bool HasFileExt(std::string fn, std::string ext) {
460 if (fn.empty()) return false;
461 if (ext.empty()) return false;
462 // if fn does not have a ext: it is maybe just an ext - compare those
463 if ((fn.length() == ext.length()) || (fn.find_last_of(".") == std::string::npos)) {
464 return fn.compare(ext) == 0;
465 }
466 if (ext[0] != '.') ext = '.' + ext;
467 to_lower(ext);
468 to_lower(fn);
469 return (fn.substr(fn.find_last_of(".")) == ext);
470}
471
472// replace file extension of input_file with new extension (with or without leading '.')
473std::string FileExtSet(std::string fn_in, std::string ext_new) {

Callers 1

IsLasLazFileFunction · 0.85

Calls 1

to_lowerFunction · 0.85

Tested by

no test coverage detected