directory_listing.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // Copyright 2015 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef NET_BASE_DIRECTORY_LISTING_H_
  5. #define NET_BASE_DIRECTORY_LISTING_H_
  6. #include <stdint.h>
  7. #include <string>
  8. #include "net/base/net_export.h"
  9. namespace base {
  10. class Time;
  11. }
  12. namespace net {
  13. // Call these functions to get the html snippet for a directory listing.
  14. // The return values of these functions are in UTF-8.
  15. NET_EXPORT std::string GetDirectoryListingHeader(const std::u16string& title);
  16. // Given the name of a file in a directory (ftp or local) and
  17. // other information (is_dir, size, modification time), it returns
  18. // the html snippet to add the entry for the file to the directory listing.
  19. // Currently, it's a script tag containing a call to a Javascript function
  20. // |addRow|.
  21. //
  22. // |name| is the file name to be displayed. |raw_bytes| will be used
  23. // as the actual target of the link (so for example, ftp links should use
  24. // server's encoding). If |raw_bytes| is an empty string, UTF-8 encoded |name|
  25. // will be used.
  26. //
  27. // Both |name| and |raw_bytes| are escaped internally.
  28. NET_EXPORT std::string GetDirectoryListingEntry(const std::u16string& name,
  29. const std::string& raw_bytes,
  30. bool is_dir,
  31. int64_t size,
  32. base::Time modified);
  33. NET_EXPORT std::string GetParentDirectoryLink();
  34. } // namespace net
  35. #endif // NET_BASE_DIRECTORY_LISTING_H_