1 /* verzeichnis.hh 2 * This file belongs to Worker, a file manager for UN*X/X11. 3 * Copyright (C) 2001-2019 Ralf Hoffmann. 4 * You can contact me at: ralf@boomerangsworld.de 5 * or http://www.boomerangsworld.de/worker 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; either version 2 of the License, or 10 * (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 */ 21 22 #ifndef VERZEICHNIS_HH 23 #define VERZEICHNIS_HH 24 25 #include "wdefines.h" 26 #include <vector> 27 #include <string> 28 29 class FileEntry; 30 31 enum { SORT_NAME = 0, 32 SORT_SIZE, 33 SORT_ACCTIME, 34 SORT_MODTIME, 35 SORT_CHGTIME, 36 SORT_TYPE, 37 SORT_OWNER, 38 SORT_INODE, 39 SORT_NLINK, 40 SORT_PERMISSION, 41 SORT_STRICT_NAME, 42 SORT_EXTENSION }; 43 44 /* for checking valid sortmode */ 45 #define ISVALID_SORTMODE(sortmode) ( ( ( sortmode & 0xff ) >= SORT_NAME ) && ( ( sortmode & 0xff ) <= SORT_EXTENSION ) ) 46 47 /* high bits used for some flags ("or" them with sort mode)*/ 48 #define SORT_REVERSE 256 49 enum {SORT_DIRLAST=512,SORT_DIRMIXED=1024}; 50 51 class Verzeichnis 52 { 53 public: 54 Verzeichnis(); 55 ~Verzeichnis(); 56 Verzeichnis( const Verzeichnis &other ); 57 Verzeichnis &operator=( const Verzeichnis &other ); 58 59 int readDir( const char * ); 60 void closeDir(); 61 int sort(int); 62 int sort(int,bool force); 63 int getSize(); 64 const char *getDir(); 65 66 int getUseSize(); 67 static int sortfunction(void*,void*,int); 68 69 FileEntry *getEntryByID( int ID ); 70 void removeElement( const FileEntry *fe ); 71 int getSerialOfIDs(); 72 static int getInvalidSerial(); 73 74 typedef std::vector<FileEntry*>::iterator verz_it; 75 verz_it begin(); 76 verz_it end(); 77 bool dirOpened() const; 78 protected: 79 80 std::vector<FileEntry*> _files; 81 bool _dir_opened; 82 83 std::string _dir_name; 84 85 std::vector<FileEntry*> _id2fe; 86 void buildID2FE(); 87 void createIDs(); 88 89 int _highest_ID_plus_one; 90 int _id_serial; 91 }; 92 93 #endif 94 95