bump product version to 5.0.4.1
[LibreOffice.git] / ucb / source / ucp / ftp / ftpdirp.hxx
blob676a5064a35cb52c3fc87fa953bd0d9bf999096e
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 /**************************************************************************
21 TODO
22 **************************************************************************
24 *************************************************************************/
25 #ifndef INCLUDED_UCB_SOURCE_UCP_FTP_FTPDIRP_HXX
26 #define INCLUDED_UCB_SOURCE_UCP_FTP_FTPDIRP_HXX
28 #include <osl/time.h>
29 #include <rtl/ustring.hxx>
30 #include <com/sun/star/util/DateTime.hpp>
33 namespace ftp {
35 /*========================================================================
37 * the DateTime structure
39 *======================================================================*/
41 struct DateTime
42 : public com::sun::star::util::DateTime
44 DateTime(const sal_uInt32& nanoSeconds,
45 const sal_uInt16& seconds,
46 const sal_uInt16& minutes,
47 const sal_uInt16& hours,
48 const sal_uInt16& day,
49 const sal_uInt16& month,
50 const sal_uInt16& year)
51 : com::sun::star::util::DateTime(nanoSeconds,
52 seconds,
53 minutes,
54 hours,
55 day,
56 month,
57 year,
58 false) { }
60 void SetYear(sal_uInt16 year) { Year = year; }
61 void SetMonth(sal_uInt16 month) { Month = month; }
62 void SetDay(sal_uInt16 day) { Day = day; }
63 // Only zero allowed and used for time-argument
64 void SetTime(sal_uInt16) { Hours = Minutes = Seconds = NanoSeconds = 0; }
65 void SetHour(sal_uInt16 hours) { Hours = hours; }
66 void SetMin(sal_uInt16 minutes) { Minutes = minutes; }
67 void SetSec(sal_uInt16 seconds) { Seconds = seconds; }
68 void SetNanoSec(sal_uInt32 nanoSec) { NanoSeconds = nanoSec; }
70 sal_uInt16 GetMonth() { return Month; }
75 /*========================================================================
77 * the directory information structure
79 *======================================================================*/
81 enum FTPDirentryMode { INETCOREFTP_FILEMODE_UNKNOWN = 0x00,
82 INETCOREFTP_FILEMODE_READ = 0x01,
83 INETCOREFTP_FILEMODE_WRITE = 0x02,
84 INETCOREFTP_FILEMODE_ISDIR = 0x04,
85 INETCOREFTP_FILEMODE_ISLINK = 0x08 };
87 struct FTPDirentry
89 OUString m_aURL;
90 OUString m_aName;
91 DateTime m_aDate;
92 sal_uInt32 m_nMode;
93 sal_uInt32 m_nSize;
95 FTPDirentry()
96 : m_aDate(0,0,0,0,0,0,0),
97 m_nMode(INETCOREFTP_FILEMODE_UNKNOWN),
98 m_nSize((sal_uInt32)(-1)) { }
100 void clear() {
101 m_aURL.clear();
102 m_aName.clear();
103 m_aDate = DateTime(0,0,0,0,0,0,0);
104 m_nMode = INETCOREFTP_FILEMODE_UNKNOWN;
105 m_nSize = sal_uInt32(-1);
108 bool isDir() const {
109 return (m_nMode & INETCOREFTP_FILEMODE_ISDIR) != 0;
112 bool isFile() const {
113 return (m_nMode & INETCOREFTP_FILEMODE_ISDIR) == 0;
118 /*========================================================================
120 * the directory parser
122 *======================================================================*/
125 class FTPDirectoryParser
127 public:
128 static bool parseDOS (
129 FTPDirentry &rEntry,
130 const sal_Char *pBuffer );
132 static bool parseVMS (
133 FTPDirentry &rEntry,
134 const sal_Char *pBuffer );
136 static bool parseUNIX (
137 FTPDirentry &rEntry,
138 const sal_Char *pBuffer );
141 private:
143 static bool parseUNIX_isSizeField (
144 const sal_Char *pStart,
145 const sal_Char *pEnd,
146 sal_uInt32 &rSize);
148 static bool parseUNIX_isMonthField (
149 const sal_Char *pStart,
150 const sal_Char *pEnd,
151 DateTime& rDateTime);
153 static bool parseUNIX_isDayField (
154 const sal_Char *pStart,
155 const sal_Char *pEnd,
156 DateTime& rDateTime);
158 static bool parseUNIX_isYearTimeField (
159 const sal_Char *pStart,
160 const sal_Char *pEnd,
161 DateTime& rDateTime);
163 static bool parseUNIX_isTime (
164 const sal_Char *pStart,
165 const sal_Char *pEnd,
166 sal_uInt16 nHour,
167 DateTime& rDateTime);
169 static bool setYear (
170 DateTime& rDateTime,
171 sal_uInt16 nYear);
173 static bool setPath (
174 OUString& rPath,
175 const sal_Char *value,
176 sal_Int32 length = -1);
183 #endif
185 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */