1// Copyright (c) 2011 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
5#ifndef NET_FTP_FTP_UTIL_H_
6#define NET_FTP_FTP_UTIL_H_
7
8#include <string>
9
10#include "base/strings/string16.h"
11#include "net/base/net_export.h"
12
13namespace base {
14class Time;
15}
16
17namespace net {
18
19class NET_EXPORT_PRIVATE FtpUtil {
20 public:
21  // Converts Unix file path to VMS path (must be a file, and not a directory).
22  static std::string UnixFilePathToVMS(const std::string& unix_path);
23
24  // Converts Unix directory path to VMS path (must be a directory).
25  static std::string UnixDirectoryPathToVMS(const std::string& unix_path);
26
27  // Converts VMS path to Unix-style path.
28  static std::string VMSPathToUnix(const std::string& vms_path);
29
30  // Converts abbreviated month (like Nov) to its number (in range 1-12).
31  // Note: in some locales abbreviations are more than three letters long,
32  // and this function also handles them correctly.
33  static bool AbbreviatedMonthToNumber(const base::string16& text, int* number);
34
35  // Converts a "ls -l" date listing to time. The listing comes in three
36  // columns. The first one contains month, the second one contains day
37  // of month. The third one is either a time (and then we guess the year based
38  // on |current_time|), or is a year (and then we don't know the time).
39  static bool LsDateListingToTime(const base::string16& month,
40                                  const base::string16& day,
41                                  const base::string16& rest,
42                                  const base::Time& current_time,
43                                  base::Time* result);
44
45  // Converts a Windows date listing to time. Returns true on success.
46  static bool WindowsDateListingToTime(const base::string16& date,
47                                       const base::string16& time,
48                                       base::Time* result);
49
50  // Skips |columns| columns from |text| (whitespace-delimited), and returns the
51  // remaining part, without leading/trailing whitespace.
52  static base::string16 GetStringPartAfterColumns(const base::string16& text,
53                                                  int columns);
54};
55
56}  // namespace net
57
58#endif  // NET_FTP_FTP_UTIL_H_
59