diff --git a/CMakeLists.txt b/CMakeLists.txt index 2e8fc3b..7853455 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,7 @@ cmake_minimum_required(VERSION 2.8) project(fatcat) +set(CMAKE_CXX_STANDARD 11) set(SOURCES core/FatEntry.cpp core/FatFilename.cpp diff --git a/src/core/FatFilename.cpp b/src/core/FatFilename.cpp index 1f62511..e765a37 100644 --- a/src/core/FatFilename.cpp +++ b/src/core/FatFilename.cpp @@ -1,5 +1,7 @@ #include #include +#include +#include #include "FatFilename.h" #include "FatEntry.h" @@ -7,22 +9,21 @@ using namespace std; #define FAT_LONG_NAME_LAST 0x40 -// Offset of letters position in a special "long file name" entry -static unsigned char longFilePos[] = { - 30, 28, 24, 22, 20, 18, 16, 14, 9, 7, 5, 3, 1 -}; - string FatFilename::getFilename() { - string rfilename; - vector::iterator it; + string filename; + vector::reverse_iterator it; + wstring_convert,char16_t> convert; - for (it=letters.begin(); it!=letters.end(); it++) { - rfilename += *it; + for (it=letters.rbegin(); it!=letters.rend(); it++) { + filename += *it; } letters.clear(); - return string(rfilename.rbegin(), rfilename.rend()); + if (!filename.length()) { + return {}; + } + return convert.to_bytes((char16_t *)filename.c_str()); } void FatFilename::append(char *buffer) @@ -35,18 +36,10 @@ void FatFilename::append(char *buffer) letters.clear(); } - int i; - for (i=0; i