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

Function HasFileExt

LASzip/src/mydefs.cpp:455–466  ·  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

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

Callers 9

mainFunction · 0.85
mainFunction · 0.85
IsLasLazFileFunction · 0.85
get_formatMethod · 0.85
openMethod · 0.85
reopenMethod · 0.85
get_file_formatMethod · 0.85
add_file_nameMethod · 0.85
add_file_nameMethod · 0.85

Calls 2

to_lowerFunction · 0.85
emptyMethod · 0.80

Tested by

no test coverage detected