00001 // Filename: virtualFileComposite.cxx 00002 // Created by: drose (03Aug02) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #include "virtualFileComposite.h" 00016 00017 TypeHandle VirtualFileComposite::_type_handle; 00018 00019 00020 //////////////////////////////////////////////////////////////////// 00021 // Function: VirtualFileComposite::get_file_system 00022 // Access: Published, Virtual 00023 // Description: Returns the VirtualFileSystem this file is associated 00024 // with. 00025 //////////////////////////////////////////////////////////////////// 00026 VirtualFileSystem *VirtualFileComposite:: 00027 get_file_system() const { 00028 return _file_system; 00029 } 00030 00031 //////////////////////////////////////////////////////////////////// 00032 // Function: VirtualFileComposite::get_filename 00033 // Access: Published, Virtual 00034 // Description: Returns the full pathname to this file within the 00035 // virtual file system. 00036 //////////////////////////////////////////////////////////////////// 00037 Filename VirtualFileComposite:: 00038 get_filename() const { 00039 return _filename; 00040 } 00041 00042 //////////////////////////////////////////////////////////////////// 00043 // Function: VirtualFileComposite::has_file 00044 // Access: Published, Virtual 00045 // Description: Returns true if this file exists, false otherwise. 00046 //////////////////////////////////////////////////////////////////// 00047 bool VirtualFileComposite:: 00048 has_file() const { 00049 return true; 00050 } 00051 00052 //////////////////////////////////////////////////////////////////// 00053 // Function: VirtualFileComposite::is_directory 00054 // Access: Published, Virtual 00055 // Description: Returns true if this file represents a directory (and 00056 // scan_directory() may be called), false otherwise. 00057 //////////////////////////////////////////////////////////////////// 00058 bool VirtualFileComposite:: 00059 is_directory() const { 00060 return true; 00061 } 00062 00063 //////////////////////////////////////////////////////////////////// 00064 // Function: VirtualFileComposite::scan_local_directory 00065 // Access: Protected, Virtual 00066 // Description: Fills file_list up with the list of files that are 00067 // within this directory, excluding those whose 00068 // basenames are listed in mount_points. Returns true 00069 // if successful, false if the file is not a directory 00070 // or the directory cannot be read. 00071 //////////////////////////////////////////////////////////////////// 00072 bool VirtualFileComposite:: 00073 scan_local_directory(VirtualFileList *file_list, 00074 const ov_set<string> &mount_points) const { 00075 bool any_ok = false; 00076 Components::const_iterator ci; 00077 for (ci = _components.begin(); ci != _components.end(); ++ci) { 00078 if ((*ci)->scan_local_directory(file_list, mount_points)) { 00079 any_ok = true; 00080 } 00081 } 00082 00083 return any_ok; 00084 }