2010-08-05 7 views

Répondre

3

Par exemple:


class CARPETAS 

creation 
    make 

feature {NONE} 

    make is 
     local 
      directory: DIRECTORY 
      path: STRING 
     do 
      path := "." -- Current directory 
      !!directory.scan_with(path) 
      list_directory(directory) 
     end 

    list_directory(directory: DIRECTORY) is 
     local 
      i: INTEGER 
     do 
      std_output.put_string("Content of " + directory.path + "%N") 
      from 
       i := directory.lower 
      until 
       i > directory.upper 
      loop 
       std_output.put_string("%T" + directory.name(i) + "%N") 
       i := i + 1 
      end 
     end 
end 
+0

avec la version récente d'Eiffel, je recommanderais d'utiliser DIRECTORY.entries local p: PATH do across dir.entries as ic loop p := ic.item.path -- then use interface of PATH, such as PATH.name end end Jocelyn

2

avec la version récente de Eiffel, je recommande d'utiliser DIRECTORY.entries

local 
    p: PATH 
do 
    across dir.entries as ic loop 
     p := ic.item.path 
      -- then use interface of PATH, such as PATH.name 
    end 
end 

noter que la bibliothèque de base_extension fournit également DIRECTORY_VISITOR, ce qui est utile pour itérer récursivement sur les annuaires

Questions connexes