Changeset 228

Show
Ignore:
Timestamp:
03/18/08 14:31:49 (4 months ago)
Author:
mattn
Message:

* implemented FindFiles?, NextFile? and ~FindFiles? for linux

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • GtkRadiant/branches/ZeroRadiant/libs/missing.h

    r227 r228  
    7474#define MK_MBUTTON          0x0010 
    7575 
     76#include <dirent.h> 
     77#include <iostream> 
     78 
    7679#endif 
    7780 
     
    214217        WIN32_FIND_DATA findFileData; 
    215218#else 
     219        DIR                             *findHandle; 
    216220#endif 
    217221}; 
  • GtkRadiant/branches/ZeroRadiant/radiant/missing.cpp

    r227 r228  
    33All rights reserved. 
    44 
    5 Redistribution and use in source and binary forms, with or without modification,  
     5Redistribution and use in source and binary forms, with or without modification, 
    66are permitted provided that the following conditions are met: 
    77 
    8 Redistributions of source code must retain the above copyright notice, this list  
     8Redistributions of source code must retain the above copyright notice, this list 
    99of conditions and the following disclaimer. 
    1010 
     
    1313other materials provided with the distribution. 
    1414 
    15 Neither the name of Loki software nor the names of its contributors may be used  
    16 to endorse or promote products derived from this software without specific prior  
    17 written permission.  
    18  
    19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''  
    20 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE  
    21 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE  
    22 DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY  
    23 DIRECT,INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES  
    24 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;  
    25 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON  
    26 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT  
    27 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS  
    28 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
     15Neither the name of Loki software nor the names of its contributors may be used 
     16to endorse or promote products derived from this software without specific prior 
     17written permission. 
     18 
     19THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' 
     20AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
     21IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
     22DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY 
     23DIRECT,INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
     24(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
     25LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 
     26ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
     27(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 
     28SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
    2929*/ 
    3030 
     
    6868    return false; 
    6969  } 
    70   
     70 
    7171  fseek (src, 0, SEEK_END); 
    7272  l = ftell (src); 
     
    141141        } 
    142142        return PATH_FILE; 
     143} 
     144 
     145FindFiles::FindFiles( const char *_directory ) { 
     146        findHandle = opendir( _directory ); 
     147} 
     148 
     149FindFiles::~FindFiles() { 
     150        if ( findHandle != NULL ) { 
     151                closedir( findHandle ); 
     152        } 
     153} 
     154 
     155const char* FindFiles::NextFile() { 
     156        struct dirent *d; 
     157 
     158        if ( findHandle == NULL ) 
     159                return NULL; 
     160 
     161        d = readdir( findHandle ); 
     162        if ( d ) 
     163                return d->d_name; 
     164        return NULL; 
    143165} 
    144166