Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

StatDirEntry.C

Go to the documentation of this file.
00001 // Copyright (C) 2001, Compaq Computer Corporation
00002 // 
00003 // This file is part of Vesta.
00004 // 
00005 // Vesta is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU Lesser General Public
00007 // License as published by the Free Software Foundation; either
00008 // version 2.1 of the License, or (at your option) any later version.
00009 // 
00010 // Vesta is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 // Lesser General Public License for more details.
00014 // 
00015 // You should have received a copy of the GNU Lesser General Public
00016 // License along with Vesta; if not, write to the Free Software
00017 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 
00019 // Last modified on Fri Apr 29 00:24:45 EDT 2005 by ken@xorian.net  
00020 //      modified on Sat Feb 12 13:10:05 PST 2000 by mann  
00021 //      modified on Fri Aug  8 19:53:52 PDT 1997 by heydon
00022 
00023 #include <sys/types.h>
00024 #include <sys/stat.h>
00025 #if defined(__digital__)
00026 #include <sys/mode.h>
00027 #endif
00028 #include <Basics.H>
00029 #include <FS.H>
00030 #include "StatDirEntry.H"
00031 #include "StatMPKFile.H"
00032 #include "StatDir.H"
00033 
00034 int DirEntry::Search(int verbose, /*INOUT*/ Stat::Collection &stats) 
00035   throw (StatError::UnevenLevels, StatError::BadMPKFile, StatError::EndOfFile,
00036          FS::Failure, FS::DoesNotExist)
00037 {
00038     assert(false);
00039     return 0; // make compiler happy
00040 }
00041 
00042 void DirEntry::FSStat(const Text &path, /*OUT*/ struct stat *buffer)
00043   throw (FS::Failure, FS::DoesNotExist)
00044 {
00045     if (stat(path.cchars(), buffer) != 0) {
00046         if (errno == ENOENT) throw FS::DoesNotExist();
00047         else throw FS::Failure(Text("stat"), path);
00048     }
00049 }
00050 
00051 DirEntry *DirEntry::Open(const Text &path, struct stat *statBuff)
00052   throw (StatError::EndOfFile, FS::Failure, FS::DoesNotExist)
00053 {
00054     DirEntry *res;
00055     struct stat buffer;
00056     if (statBuff == (struct stat *)NULL) {
00057         statBuff = &buffer;
00058         FSStat(path, /*OUT*/ statBuff);
00059     }
00060     if (S_ISDIR(statBuff->st_mode)) {
00061       res = NEW_CONSTR(DirObj, (path));
00062     } else {
00063       assert(S_ISREG(statBuff->st_mode));
00064       res = NEW_CONSTR(MPKFileObj, (path));
00065     }
00066     return res;
00067 }

Generated on Mon May 8 00:48:36 2006 for Vesta by  doxygen 1.4.2