Main Page   Class Hierarchy   Compound List   File List   Compound Members  

CAVERNmisc_fileList_c.hxx

00001 /******************************************************************
00002  * CAVERNsoft
00003  * Copyright (C) 1994-2000 Electronic Visualization Laboratory,
00004  * all rights reserved
00005  * By Jason Leigh, Yong-joo Cho, Naveen Krishnaprasad, Chris Scharver,
00006  * Stuart Bailey, Atul Nayak, Shalini Venkataraman
00007  * University of Illinois at Chicago
00008  * 
00009  * This publication and its text and code may not be copied for commercial 
00010  * use without the express written permission of the University of Illinois
00011  * at Chicago.
00012  * The contributors disclaim any representation of warranty: use this
00013  * code at your own risk.
00014  * Direct questions, comments etc to cavern@evl.uic.edu
00015  ******************************************************************/
00016 
00017 #if (defined(__sgi) || defined(linux) || defined(sun))
00018 #ifndef _CAVERNMISC_FILELIST_C
00019 #define _CAVERNMISC_FILELIST_C
00020 
00021 #ifdef linux
00022 #ifndef _GNU_SOURCE
00023  #define _GNU_SOURCE
00024 #endif
00025 #endif
00026 
00027 
00028 #include <stdio.h>
00029 #include <ftw.h>
00030 #include <sys/stat.h>
00031 #include <sys/types.h>
00032 #include <string.h>
00033 #include <time.h>
00034 #include "CAVERNnet_datapack_c.hxx"
00035 
00038 class CAVERNmisc_fileInfo_c
00039 {
00040 
00041 protected:
00042     char* fileName;         //The file name with the full path
00043     long fileSize;          //The size of the file
00044     long timeStamp;         //Time stamp in seconds
00045     int objectType;         //To specify if its  file or a directory
00046     char* leafName;         //The leaf name of the file (without the full path)
00047     void setLeafName(char* path);
00048 public:
00049     
00051 
00052     static const int OK; /* =0 */
00054     static const int FAILED; /* = -1 */
00056     static const int FILE_TYPE; /* = FTW_F */
00058     static const int DIRECTORY_TYPE; /* = FTW_D */
00060     static const int DIRECTORY_TYPE_CANNOT_BE_READ; /* = FTW_DNR */
00062     
00063     CAVERNmisc_fileInfo_c();
00064     ~CAVERNmisc_fileInfo_c();
00065     
00074     void setFileInfo(char* path, char* fName, long fSize, long tStamp, int type);
00075     
00081     void getFileName(char*& fName);
00082 
00088     void getLeafName(char*& lName);
00089 
00090 
00096     long getFileSize();
00097     
00103     long getTimeStamp();
00104 
00109     int getObjectType();
00110      
00116     int getPackingSize();
00117     
00123     int packFileInfo(CAVERNnet_datapack_c* packer); 
00124     
00131     int unpackFileInfo(CAVERNnet_datapack_c* packer, char* path);
00132     
00136     void displayFileInfo();
00137 };
00138 
00143 class CAVERNmisc_fileList_c
00144 {
00145 private:    
00146     int depth;
00147     int I_ALLOCATED_MEMORY;  //used to check what memory to deallocate
00148     static int ftwCallBack(const char* fname, const struct stat* statBuf, int objectType, struct FTW* ftwstruct);
00149     static int ftwDummyCallBack(const char* fname, const struct stat* statBuf, int objectType, struct FTW* ftwstruct);
00150     static CAVERNmisc_fileList_c* thisInstance ;
00151 public:
00153 
00154         static const int OK; /* =0 */
00156         static const int FAILED; /* = -1 */
00158         static const int LIST_RECURSIVELY; /* = 2 */
00160         static const int SKIP_RECURSION; /* = 3 */
00162         static const int TRAVERSE_LINKS; /* = 4 */
00164         static const int DO_NOT_TRAVERSE_LINKS; /* = 5 */
00166     
00167     char* path;
00168     int noFiles;
00169     int fileCount;
00170     int doRecursion;
00171     CAVERNmisc_fileInfo_c* fileList;
00172                         
00173     CAVERNmisc_fileList_c();
00174     ~CAVERNmisc_fileList_c();
00175     
00180     void setDepth(int newDepth);
00181 
00193     int buildFileList(char* dirName, int recursion = SKIP_RECURSION, int linkTraversal = DO_NOT_TRAVERSE_LINKS);
00194     
00200     int getNoFiles();
00201    
00207     int packFileList(CAVERNnet_datapack_c* packer);
00208     
00214     int getDataPackingSize();
00215 
00224     int unpackfileList(CAVERNnet_datapack_c* packer, char* path, CAVERNmisc_fileInfo_c* list, int fileCount);
00225     
00229     void displayFileList();
00230 };
00231 
00232 #endif
00233 #endif

Generated at Mon Jul 2 14:24:42 2001 for CAVERNsoft by doxygen1.2.8-20010617 written by Dimitri van Heesch, © 1997-2001