Bump for 3.6-28
[LibreOffice.git] / ucb / source / ucp / ftp / ftpdirp.hxx
blobce0ed266a538d02d87ee84d7b50905f43f6a12a5
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 /**************************************************************************
30 TODO
31 **************************************************************************
33 *************************************************************************/
34 #ifndef _FTP_FTPDIRP_HXX_
35 #define _FTP_FTPDIRP_HXX_
37 #include <osl/time.h>
38 #include <rtl/ustring.hxx>
39 #include <com/sun/star/util/DateTime.hpp>
42 namespace ftp {
44 /*========================================================================
46 * the DateTime structure
48 *======================================================================*/
50 struct DateTime
51 : public com::sun::star::util::DateTime
53 DateTime(const sal_uInt16& hundredthSeconds,
54 const sal_uInt16& seconds,
55 const sal_uInt16& minutes,
56 const sal_uInt16& hours,
57 const sal_uInt16& day,
58 const sal_uInt16& month,
59 const sal_uInt16& year) SAL_THROW(())
60 : com::sun::star::util::DateTime(hundredthSeconds,
61 seconds,
62 minutes,
63 hours,
64 day,
65 month,
66 year) { }
68 void SetYear(sal_uInt16 year) { Year = year; }
69 void SetMonth(sal_uInt16 month) { Month = month; }
70 void SetDay(sal_uInt16 day) { Day = day; }
71 // Only zero allowed and used for time-argument
72 void SetTime(sal_uInt16) { Hours = Minutes = Seconds = HundredthSeconds = 0; }
73 void SetHour(sal_uInt16 hours) { Hours = hours; }
74 void SetMin(sal_uInt16 minutes) { Minutes = minutes; }
75 void SetSec(sal_uInt16 seconds) { Seconds = seconds; }
76 void Set100Sec(sal_uInt16 hundredthSec) { HundredthSeconds = hundredthSec; }
78 sal_uInt16 GetMonth(void) { return Month; }
83 /*========================================================================
85 * the directory information structure
87 *======================================================================*/
89 enum FTPDirentryMode { INETCOREFTP_FILEMODE_UNKNOWN = 0x00,
90 INETCOREFTP_FILEMODE_READ = 0x01,
91 INETCOREFTP_FILEMODE_WRITE = 0x02,
92 INETCOREFTP_FILEMODE_ISDIR = 0x04,
93 INETCOREFTP_FILEMODE_ISLINK = 0x08 };
95 struct FTPDirentry
97 rtl::OUString m_aURL;
98 rtl::OUString m_aName;
99 DateTime m_aDate;
100 sal_uInt32 m_nMode;
101 sal_uInt32 m_nSize;
103 FTPDirentry(void)
104 : m_aDate(0,0,0,0,0,0,0),
105 m_nMode(INETCOREFTP_FILEMODE_UNKNOWN),
106 m_nSize((sal_uInt32)(-1)) { }
108 void clear() {
109 m_aURL = m_aName = rtl::OUString();
110 m_aDate = DateTime(0,0,0,0,0,0,0);
111 m_nMode = INETCOREFTP_FILEMODE_UNKNOWN;
112 m_nSize = sal_uInt32(-1);
115 bool isDir() const {
116 return bool(m_nMode && INETCOREFTP_FILEMODE_ISDIR);
119 bool isFile() const {
120 return ! bool(m_nMode && INETCOREFTP_FILEMODE_ISDIR);
125 /*========================================================================
127 * the directory parser
129 *======================================================================*/
132 class FTPDirectoryParser
134 public:
135 static sal_Bool parseDOS (
136 FTPDirentry &rEntry,
137 const sal_Char *pBuffer );
139 static sal_Bool parseVMS (
140 FTPDirentry &rEntry,
141 const sal_Char *pBuffer );
143 static sal_Bool parseUNIX (
144 FTPDirentry &rEntry,
145 const sal_Char *pBuffer );
148 private:
150 static sal_Bool parseUNIX_isSizeField (
151 const sal_Char *pStart,
152 const sal_Char *pEnd,
153 sal_uInt32 &rSize);
155 static sal_Bool parseUNIX_isMonthField (
156 const sal_Char *pStart,
157 const sal_Char *pEnd,
158 DateTime& rDateTime);
160 static sal_Bool parseUNIX_isDayField (
161 const sal_Char *pStart,
162 const sal_Char *pEnd,
163 DateTime& rDateTime);
165 static sal_Bool parseUNIX_isYearTimeField (
166 const sal_Char *pStart,
167 const sal_Char *pEnd,
168 DateTime& rDateTime);
170 static sal_Bool parseUNIX_isTime (
171 const sal_Char *pStart,
172 const sal_Char *pEnd,
173 sal_uInt16 nHour,
174 DateTime& rDateTime);
176 static sal_Bool setYear (
177 DateTime& rDateTime,
178 sal_uInt16 nYear);
180 static sal_Bool setPath (
181 rtl::OUString& rPath,
182 const sal_Char *value,
183 sal_Int32 length = -1);
190 #endif
192 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */