Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Changeset 2543

Show
Ignore:
Timestamp:
09/03/07 01:12:01 (1 year ago)
Author:
kris
Message:

removed indirect mutating methods from PathView?, so that it is more compatible with VFS

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/tango/io/FilePath.d

    r2517 r2543  
    9494                        folder_,                // path before name 
    9595                        suffix_;                // after rightmost '.' 
     96 
     97        /*********************************************************************** 
     98 
     99                Filter used for screening paths via toList() 
     100 
     101        ***********************************************************************/ 
     102 
     103        public alias bool delegate (FilePath, bool) Filter; 
    96104 
    97105 
     
    625633        /*********************************************************************** 
    626634 
    627                 List the set of filenames within this directory. All 
     635                List the set of filenames within this folder. All 
    628636                filenames are null terminated, though the null itself 
    629637                is hidden at the end of each name (not exposed by the 
     
    658666        /*********************************************************************** 
    659667 
    660                 List the set of filenames within this directory, using 
     668                List the set of filenames within this folder, using 
    661669                the provided filter to control the list: 
    662670                --- 
     
    11261134                /*************************************************************** 
    11271135 
    1128                         List the set of filenames within this directory. 
    1129  
    1130                         All filenames are null terminated and are passed 
    1131                         to the provided delegate as such, along with the 
    1132                         path prefix and whether the entry is a directory 
    1133                         or not. 
    1134  
    1135                 ***************************************************************/ 
    1136  
    1137                 final FilePath toList (void delegate (char[] path, char[] file, bool dir) dg) 
     1136                        List the set of filenames within this folder. 
     1137 
     1138                        Each path and filename is passed to the provided  
     1139                        delegate, along with the path prefix and whether  
     1140                        the entry is a folder or not. 
     1141 
     1142                        Returns the number of files scanned. 
     1143 
     1144                ***************************************************************/ 
     1145 
     1146                final uint toList (void delegate (char[] path, char[] file, bool dir) dg) 
    11381147                { 
    11391148                        HANDLE                  h; 
     1149                        uint                    count; 
    11401150                        char[]                  prefix; 
    11411151                        char[MAX_PATH+1]        tmp = void; 
     
    11861196                           // skip hidden/system files 
    11871197                           if ((fileinfo.dwFileAttributes & (FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN)) is 0) 
    1188                                 dg (prefix, str, (fileinfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0); 
     1198                              { 
     1199                              dg (prefix, str, (fileinfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0); 
     1200                              ++count; 
     1201                              } 
    11891202 
    11901203                           } while (next); 
    11911204 
    1192                         return this
     1205                        return count
    11931206                } 
    11941207        } 
     
    14101423                /*************************************************************** 
    14111424 
    1412                         List the set of filenames within this directory. 
    1413  
    1414                         All filenames are null terminated and are passed 
    1415                         to the provided delegate as such, along with the 
    1416                         path prefix and whether the entry is a directory 
    1417                         or not. 
    1418  
    1419                 ***************************************************************/ 
    1420  
    1421                 final FilePath toList (void delegate (char[] path, char[] file, bool dir) dg) 
     1425                        List the set of filenames within this folder. 
     1426 
     1427                        Each path and filename is passed to the provided  
     1428                        delegate, along with the path prefix and whether  
     1429                        the entry is a folder or not. 
     1430 
     1431                        Returns the number of files scanned. 
     1432 
     1433                ***************************************************************/ 
     1434 
     1435                final uint toList (void delegate (char[] path, char[] file, bool dir) dg) 
    14221436                { 
    14231437                        DIR*            dir; 
     
    14261440                        char[]          prefix; 
    14271441                        char[]          sfnbuf; 
     1442                        uint            count; 
    14281443 
    14291444                        dir = tango.stdc.posix.dirent.opendir (this.cString.ptr); 
     
    14571472                                                 : (sbuf.st_mode & S_IFDIR) != 0; 
    14581473                              dg (prefix, str, isDir); 
     1474                              ++count; 
    14591475                              } 
    14601476 
    1461                         return this
     1477                        return count
    14621478                } 
    14631479        } 
     
    14721488interface PathView 
    14731489{ 
    1474         public  alias bool delegate (FilePath, bool) Filter; 
    1475  
    14761490        /*********************************************************************** 
    14771491 
     
    16301644        /*********************************************************************** 
    16311645 
    1632                 Create an entire path consisting of this folder along with 
    1633                 all parent folders. The path must not contain '.' or '..' 
    1634                 segments. Related methods include PathUtil.normalize() and 
    1635                 FileSystem.absolutePath() 
    1636  
    1637                 Returns: a chaining reference (this) 
    1638  
    1639                 Throws: IOException upon systen errors 
    1640  
    1641                 Throws: IllegalArgumentException if the path contains invalid 
    1642                         path segment names (such as '.' or '..') or a segment 
    1643                         exists but as a file instead of a folder 
    1644  
    1645         ***********************************************************************/ 
    1646  
    1647         abstract FilePath create (); 
    1648  
    1649         /*********************************************************************** 
    1650  
    1651                 Create a new file 
    1652  
    1653         ***********************************************************************/ 
    1654  
    1655         abstract FilePath createFile (); 
    1656  
    1657         /*********************************************************************** 
    1658  
    1659                 Create a new directory 
    1660  
    1661         ***********************************************************************/ 
    1662  
    1663         abstract FilePath createFolder (); 
    1664  
    1665         /*********************************************************************** 
    1666  
    16671646                Return the file length (in bytes) 
    16681647 
     
    16941673 
    16951674        abstract Stamps timeStamps (); 
    1696  
    1697         /*********************************************************************** 
    1698  
    1699                 List the set of filenames within this directory, using 
    1700                 the provided filter to control the list: 
    1701                 --- 
    1702                 bool delegate (FilePath path, bool isFolder) Filter 
    1703                 --- 
    1704  
    1705                 Returning true from the filter includes the given path,  
    1706                 whilst returning false excludes it. Parameter 'isFolder' 
    1707                 indicates whether the path is a file or folder 
    1708  
    1709                 Note that paths composed of '.' characters are ignored. 
    1710  
    1711         ***********************************************************************/ 
    1712  
    1713         abstract FilePath[] toList (Filter filter = null); 
    1714  
    1715         /*********************************************************************** 
    1716  
    1717                 List the set of filenames within this directory. 
    1718  
    1719                 All filenames are null terminated and are passed 
    1720                 to the provided delegate as such, along with the 
    1721                 path prefix and whether the entry is a directory 
    1722                 or not. 
    1723  
    1724         ***********************************************************************/ 
    1725          
    1726         abstract FilePath toList (void delegate (char[], char[], bool) dg); 
    17271675} 
    17281676