[Swift-devel] Q of traversing all files in one directory

Zhao Zhang zhaozhang at uchicago.edu
Mon Dec 29 14:17:43 CST 2008


Thank you guys. I got it.

zhao

Mihael Hategan wrote:
> On Mon, 2008-12-29 at 13:05 -0600, Zhao Zhang wrote:
>   
>> Hi, All
>>
>> Sorry to send out a Q in Holiday time.
>> My question is about Chapter 3.7 of swift tutorial, the foreach 
>> statement and regexp_mapper.
>>
>> In the following code example, all input files are listed in the string.
>>
>> string inputNames = "one.txt two.txt three.txt";  
>>   
>> messagefile inputfiles[] <fixed_array_mapper; files=inputNames>;    
>>   
>> foreach f in inputfiles {  
>>   countfile c <regexp_mapper;  
>>                source=@f,  
>>                match="(.*)txt",  
>>                transform="\\1count">;  
>>   c = countwords(f);  
>> }
>>
>>
>> How can I say that
>>
>> foreach file in a directory {
>>    outfile = app(file)
>> }
>>
>> In swift ?
>>     
>
> You use the filesystem mapper instead.
>
> messagefile inputfiles[] <filesys_mapper; location="some/dir">;
>
> (refer to the docs for the full set of parameters for that mapper).
>
>
>   



More information about the Swift-devel mailing list