| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- // Copyright (C) 2009-2021, Panagiotis Christopoulos Charitos and contributors.
- // All rights reserved.
- // Code licensed under the BSD License.
- // http://www.anki3d.org/LICENSE
- #include <AnKi/Util/Filesystem.h>
- namespace anki
- {
- void getFilepathExtension(const CString& filename, StringAuto& out)
- {
- const char* pc = std::strrchr(filename.cstr(), '.');
- if(pc == nullptr)
- {
- // Do nothing
- }
- else
- {
- ++pc;
- if(*pc != '\0')
- {
- out.create(CString(pc));
- }
- }
- }
- void getFilepathFilename(const CString& filename, StringAuto& out)
- {
- const char* pc = std::strrchr(filename.cstr(), '/');
- if(pc == nullptr)
- {
- out.create(filename);
- }
- else
- {
- ++pc;
- if(*pc != '\0')
- {
- out.create(CString(pc));
- }
- }
- }
- void getParentFilepath(const CString& filename, StringAuto& out)
- {
- const char* pc = std::strrchr(filename.cstr(), '/');
- if(pc == nullptr)
- {
- out.create("");
- }
- else
- {
- out.create(filename.cstr(), pc);
- }
- }
- } // end namespace anki
|