Advertisement
Guest User

Untitled

a guest
Aug 1st, 2012
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. def generate_files(path, items)
  2. trail = path.split("/")
  3. return "" if trail.length < 2
  4.  
  5. files = ""
  6. items.each do |f, hide|
  7. h = hide ? '1' : '0'
  8. files << <<-FILES
  9. <D:response xmlns:lp1="DAV:" xmlns:lp2="http://apache.org/dav/props/">
  10. <D:href>#{path}#{f}</D:href>
  11. <D:propstat>
  12. <D:prop>
  13. <lp1:resourcetype/>
  14. <lp1:creationdate>#{gen_datestamp}</lp1:creationdate>
  15. <lp1:getcontentlength>#{rand(0x10000)+120}</lp1:getcontentlength>
  16. <lp1:getlastmodified>#{gen_timestamp}</lp1:getlastmodified>
  17. <lp1:getetag>"#{"%.16x" % rand(0x100000000)}"</lp1:getetag>
  18. <lp2:executable>T</lp2:executable>
  19. <D:supportedlock>
  20. <D:lockentry>
  21. <D:lockscope><D:exclusive/></D:lockscope>
  22. <D:locktype><D:write/></D:locktype>
  23. </D:lockentry>
  24. <D:lockentry>
  25. <D:lockscope><D:shared/></D:lockscope>
  26. <D:locktype><D:write/></D:locktype>
  27. </D:lockentry>
  28. </D:supportedlock>
  29. <D:lockdiscovery/>
  30. <D:getcontenttype>application/octet-stream</D:getcontenttype>
  31. </D:prop>
  32. <D:status>HTTP/1.1 200 OK</D:status>
  33. <D:ishidden b:dt="boolean">#{h}</D:ishidden>
  34. </D:propstat>
  35. </D:response>
  36. FILES
  37. end
  38.  
  39. files = files.gsub(/^\t\t\t/, '')
  40.  
  41. return files
  42. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement