Skip to content

Commit

Permalink
updated filesystem to load sub folder correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
onkis committed May 18, 2010
1 parent 99ecebd commit 2b58945
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions lib/sproutcore/rack/filesystem.rb
Expand Up @@ -104,23 +104,22 @@ def list_files(original_path)
results = []
@id = 0
with_sanitized_path(original_path) do |root_path|
results = folder_contents(root_path, root_path)
results = folder_contents(root_path)
end
success(results.to_json)
end

def folder_contents(dir, root_path)
def folder_contents(dir)
results = []

Dir.new(dir).each do |path|
name = path
path = dir + path
sc_path = path.gsub(root_path,"")
sc_path = sc_path.gsub(name,"")
sc_path = dir.gsub(root_dir,"")
if FileTest.directory?(path)
if not (File.basename(path)[0] == ?. or @ignore_directories.include?(File.basename(path)))
results<< {:type => :Dir, :dir => sc_path, :name =>name,
:contents=> folder_contents(path+"/", root_path), :id => @id+=1}
:contents=> folder_contents(path+"/"), :id => @id+=1}
end
else #just a regular file
results<< {:type => :File, :dir => sc_path, :name => name, :id => @id+=1 }
Expand Down

0 comments on commit 2b58945

Please sign in to comment.