| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- // 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
|