void fs::file_ptr::reset(const file& f) { reset(); if (f) { #ifdef _WIN32 const HANDLE handle = ::CreateFileMapping((HANDLE)f.m_fd, NULL, PAGE_READONLY, 0, 0, NULL); m_ptr = (char*)::MapViewOfFile(handle, FILE_MAP_READ, 0, 0, 0); m_size = f.size(); ::CloseHandle(handle); #else m_ptr = (char*)::mmap(nullptr, m_size = f.size(), PROT_READ, MAP_SHARED, f.m_fd, 0); if (m_ptr == (void*)-1) m_ptr = nullptr; #endif } }
bool file::operator<( const file &other ) const { if( sorting == by_size ) return size() < other.size(); if( sorting == by_date ) return date() < other.date(); if( sorting == by_extension ) //@todo: lower!, buggy return ext() < other.ext(); if( sorting == by_type ) return is_dir() < other.is_dir(); //if( sorting == by_name ) return pathfile < other.pathfile; }
bool file::operator==( const file &other ) const { if( sorting == by_size ) return size() == other.size(); if( sorting == by_date ) return date() == other.date(); if( sorting == by_extension ) return ext() == other.ext(); if( sorting == by_type ) return is_dir() == other.is_dir(); //if( sorting == by_name ) return pathfile == other.pathfile; }