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