diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-19 23:04:29 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-19 23:04:29 +0000 |
commit | 721c3f17a7fb36edaa17f607a11db9c82ba720ca (patch) | |
tree | c78e993a5474acdb2751c222db8787d7aa482301 /net/base/net_util.cc | |
parent | f785ad125747f9125c952c7e74f2154098ee15a9 (diff) | |
download | chromium_src-721c3f17a7fb36edaa17f607a11db9c82ba720ca.zip chromium_src-721c3f17a7fb36edaa17f607a11db9c82ba720ca.tar.gz chromium_src-721c3f17a7fb36edaa17f607a11db9c82ba720ca.tar.bz2 |
Port directory lister so test shell can view file directories.
Review URL: http://codereview.chromium.org/11437
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5725 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base/net_util.cc')
-rw-r--r-- | net/base/net_util.cc | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/net/base/net_util.cc b/net/base/net_util.cc index 05419fb..3946c6b 100644 --- a/net/base/net_util.cc +++ b/net/base/net_util.cc @@ -23,6 +23,7 @@ #include "net/base/net_util.h" #include "base/basictypes.h" +#include "base/file_path.h" #include "base/file_util.h" #include "base/logging.h" #include "base/path_service.h" @@ -798,12 +799,22 @@ std::string CanonicalizeHost(const std::wstring& host, bool* is_ip_address) { return CanonicalizeHost(converted_host, is_ip_address); } -#ifdef OS_WIN std::string GetDirectoryListingHeader(const std::string& title) { +#if defined(OS_WIN) std::string result = NetModule::GetResource(IDR_DIR_HEADER_HTML); if (result.empty()) { NOTREACHED() << "expected resource not found"; } +#elif defined(OS_POSIX) + // TODO(estade): Temporary hack. Remove these platform #ifdefs when we + // have implemented resources for non-Windows platforms. + LOG(INFO) << "FIXME: hacked resource loading"; + FilePath path; + PathService::Get(base::DIR_EXE, &path); + path = path.Append("../../net/base/dir_header.html"); + std::string result; + file_util::ReadFileToString(path.ToWStringHack(), &result); +#endif result.append("<script>start("); string_escape::JavascriptDoubleQuote(title, true, &result); @@ -813,16 +824,16 @@ std::string GetDirectoryListingHeader(const std::string& title) { } std::string GetDirectoryListingEntry(const std::string& name, - DWORD attrib, + bool is_dir, int64 size, - const FILETIME* modified) { + const Time& modified) { std::string result; result.append("<script>addRow("); string_escape::JavascriptDoubleQuote(name, true, &result); result.append(","); string_escape::JavascriptDoubleQuote( EscapePath(name), true, &result); - if (attrib & FILE_ATTRIBUTE_DIRECTORY) { + if (is_dir) { result.append(",1,"); } else { result.append(",0,"); @@ -835,9 +846,8 @@ std::string GetDirectoryListingEntry(const std::string& name, std::wstring modified_str; // |modified| can be NULL in FTP listings. - if (modified) { - Time time(Time::FromFileTime(*modified)); - modified_str = base::TimeFormatShortDateAndTime(time); + if (!modified.is_null()) { + modified_str = base::TimeFormatShortDateAndTime(modified); } string_escape::JavascriptDoubleQuote(modified_str, true, &result); @@ -845,7 +855,6 @@ std::string GetDirectoryListingEntry(const std::string& name, return result; } -#endif std::wstring StripWWW(const std::wstring& text) { const std::wstring www(L"www."); |