1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ftpdirp.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 /**************************************************************************
33 **************************************************************************
35 *************************************************************************/
36 #ifndef _FTP_FTPDIRP_HXX_
37 #define _FTP_FTPDIRP_HXX_
40 #include <rtl/ustring.hxx>
41 #include <com/sun/star/util/DateTime.hpp>
46 /*========================================================================
48 * the DateTime structure
50 *======================================================================*/
53 : public com::sun::star::util::DateTime
55 DateTime(const sal_uInt16
& hundredthSeconds
,
56 const sal_uInt16
& seconds
,
57 const sal_uInt16
& minutes
,
58 const sal_uInt16
& hours
,
59 const sal_uInt16
& day
,
60 const sal_uInt16
& month
,
61 const sal_uInt16
& year
) SAL_THROW( () )
62 : com::sun::star::util::DateTime(hundredthSeconds
,
70 void SetYear(sal_uInt16 year
) { Year
= year
; }
71 void SetMonth(sal_uInt16 month
) { Month
= month
; }
72 void SetDay(sal_uInt16 day
) { Day
= day
; }
73 // Only zero allowed and used for time-argument
74 void SetTime(sal_uInt16
) { Hours
= Minutes
= Seconds
= HundredthSeconds
= 0; }
75 void SetHour(sal_uInt16 hours
) { Hours
= hours
; }
76 void SetMin(sal_uInt16 minutes
) { Minutes
= minutes
; }
77 void SetSec(sal_uInt16 seconds
) { Seconds
= seconds
; }
78 void Set100Sec(sal_uInt16 hundredthSec
) { HundredthSeconds
= hundredthSec
; }
80 sal_uInt16
GetMonth(void) { return Month
; }
85 /*========================================================================
87 * the directory information structure
89 *======================================================================*/
91 enum FTPDirentryMode
{ INETCOREFTP_FILEMODE_UNKNOWN
= 0x00,
92 INETCOREFTP_FILEMODE_READ
= 0x01,
93 INETCOREFTP_FILEMODE_WRITE
= 0x02,
94 INETCOREFTP_FILEMODE_ISDIR
= 0x04,
95 INETCOREFTP_FILEMODE_ISLINK
= 0x08 };
100 rtl::OUString m_aName
;
106 : m_aDate(0,0,0,0,0,0,0),
107 m_nMode(INETCOREFTP_FILEMODE_UNKNOWN
),
108 m_nSize((sal_uInt32
)(-1)) { }
111 m_aURL
= m_aName
= rtl::OUString();
112 m_aDate
= DateTime(0,0,0,0,0,0,0);
113 m_nMode
= INETCOREFTP_FILEMODE_UNKNOWN
;
114 m_nSize
= sal_uInt32(-1);
118 return bool(m_nMode
&& INETCOREFTP_FILEMODE_ISDIR
);
121 bool isFile() const {
122 return ! bool(m_nMode
&& INETCOREFTP_FILEMODE_ISDIR
);
127 /*========================================================================
129 * the directory parser
131 *======================================================================*/
134 class FTPDirectoryParser
137 static sal_Bool
parseDOS (
139 const sal_Char
*pBuffer
);
141 static sal_Bool
parseVMS (
143 const sal_Char
*pBuffer
);
145 static sal_Bool
parseUNIX (
147 const sal_Char
*pBuffer
);
149 static sal_Bool
parseUNKNOWN (
151 const sal_Char
*pBuffer
,
157 static sal_Bool
parseUNIX_isSizeField (
158 const sal_Char
*pStart
,
159 const sal_Char
*pEnd
,
162 static sal_Bool
parseUNIX_isMonthField (
163 const sal_Char
*pStart
,
164 const sal_Char
*pEnd
,
165 DateTime
& rDateTime
);
167 static sal_Bool
parseUNIX_isDayField (
168 const sal_Char
*pStart
,
169 const sal_Char
*pEnd
,
170 DateTime
& rDateTime
);
172 static sal_Bool
parseUNIX_isYearTimeField (
173 const sal_Char
*pStart
,
174 const sal_Char
*pEnd
,
175 DateTime
& rDateTime
);
177 static sal_Bool
parseUNIX_isTime (
178 const sal_Char
*pStart
,
179 const sal_Char
*pEnd
,
181 DateTime
& rDateTime
);
183 static sal_Bool
setYear (
187 static sal_Bool
setPath (
188 rtl::OUString
& rPath
,
189 const sal_Char
*value
,
190 sal_Int32 length
= -1);