LCOV - code coverage report
Current view: top level - ucb/source/ucp/ftp - ftpdirp.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 20 0.0 %
Date: 2012-08-25 Functions: 0 15 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*
       3                 :            :  * This file is part of the LibreOffice project.
       4                 :            :  *
       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/.
       8                 :            :  *
       9                 :            :  * This file incorporates work covered by the following license notice:
      10                 :            :  *
      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 .
      18                 :            :  */
      19                 :            : 
      20                 :            : /**************************************************************************
      21                 :            :                                 TODO
      22                 :            :  **************************************************************************
      23                 :            : 
      24                 :            :  *************************************************************************/
      25                 :            : #ifndef _FTP_FTPDIRP_HXX_
      26                 :            : #define _FTP_FTPDIRP_HXX_
      27                 :            : 
      28                 :            : #include <osl/time.h>
      29                 :            : #include <rtl/ustring.hxx>
      30                 :            : #include <com/sun/star/util/DateTime.hpp>
      31                 :            : 
      32                 :            : 
      33                 :            : namespace ftp {
      34                 :            : 
      35                 :            :     /*========================================================================
      36                 :            :      *
      37                 :            :      * the DateTime structure
      38                 :            :      *
      39                 :            :      *======================================================================*/
      40                 :            : 
      41                 :            :     struct DateTime
      42                 :            :         : public com::sun::star::util::DateTime
      43                 :            :     {
      44                 :          0 :         DateTime(const sal_uInt16& hundredthSeconds,
      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) SAL_THROW(())
      51                 :            :                      : com::sun::star::util::DateTime(hundredthSeconds,
      52                 :            :                                                       seconds,
      53                 :            :                                                       minutes,
      54                 :            :                                                       hours,
      55                 :            :                                                       day,
      56                 :            :                                                       month,
      57                 :          0 :                                                       year) { }
      58                 :            : 
      59                 :          0 :         void SetYear(sal_uInt16 year) { Year = year; }
      60                 :          0 :         void SetMonth(sal_uInt16 month) { Month = month; }
      61                 :          0 :         void SetDay(sal_uInt16 day) { Day = day; }
      62                 :            :         // Only zero allowed and used for time-argument
      63                 :          0 :         void SetTime(sal_uInt16) { Hours = Minutes = Seconds = HundredthSeconds = 0; }
      64                 :          0 :         void SetHour(sal_uInt16 hours) { Hours = hours; }
      65                 :          0 :         void SetMin(sal_uInt16 minutes) { Minutes = minutes; }
      66                 :          0 :         void SetSec(sal_uInt16 seconds) { Seconds = seconds; }
      67                 :          0 :         void Set100Sec(sal_uInt16 hundredthSec) { HundredthSeconds = hundredthSec; }
      68                 :            : 
      69                 :          0 :         sal_uInt16 GetMonth(void) { return Month; }
      70                 :            :     };
      71                 :            : 
      72                 :            : 
      73                 :            : 
      74                 :            : /*========================================================================
      75                 :            :  *
      76                 :            :  * the directory information structure
      77                 :            :  *
      78                 :            :  *======================================================================*/
      79                 :            : 
      80                 :            :     enum FTPDirentryMode { INETCOREFTP_FILEMODE_UNKNOWN = 0x00,
      81                 :            :                            INETCOREFTP_FILEMODE_READ = 0x01,
      82                 :            :                            INETCOREFTP_FILEMODE_WRITE = 0x02,
      83                 :            :                            INETCOREFTP_FILEMODE_ISDIR = 0x04,
      84                 :            :                            INETCOREFTP_FILEMODE_ISLINK = 0x08 };
      85                 :            : 
      86                 :          0 :     struct FTPDirentry
      87                 :            :     {
      88                 :            :         rtl::OUString                       m_aURL;
      89                 :            :         rtl::OUString                       m_aName;
      90                 :            :         DateTime                            m_aDate;
      91                 :            :         sal_uInt32                          m_nMode;
      92                 :            :         sal_uInt32                          m_nSize;
      93                 :            : 
      94                 :          0 :         FTPDirentry(void)
      95                 :            :             : m_aDate(0,0,0,0,0,0,0),
      96                 :            :               m_nMode(INETCOREFTP_FILEMODE_UNKNOWN),
      97                 :          0 :               m_nSize((sal_uInt32)(-1)) { }
      98                 :            : 
      99                 :          0 :         void clear() {
     100                 :          0 :             m_aURL = m_aName = rtl::OUString();
     101                 :          0 :             m_aDate = DateTime(0,0,0,0,0,0,0);
     102                 :          0 :             m_nMode = INETCOREFTP_FILEMODE_UNKNOWN;
     103                 :          0 :             m_nSize = sal_uInt32(-1);
     104                 :          0 :         }
     105                 :            : 
     106                 :            :         bool isDir() const {
     107                 :            :             return bool(m_nMode && INETCOREFTP_FILEMODE_ISDIR);
     108                 :            :         }
     109                 :            : 
     110                 :            :         bool isFile() const {
     111                 :            :             return ! bool(m_nMode && INETCOREFTP_FILEMODE_ISDIR);
     112                 :            :         }
     113                 :            :     };
     114                 :            : 
     115                 :            : 
     116                 :            : /*========================================================================
     117                 :            :  *
     118                 :            :  * the directory parser
     119                 :            :  *
     120                 :            :  *======================================================================*/
     121                 :            : 
     122                 :            : 
     123                 :            :     class FTPDirectoryParser
     124                 :            :     {
     125                 :            :     public:
     126                 :            :         static sal_Bool parseDOS (
     127                 :            :             FTPDirentry &rEntry,
     128                 :            :             const sal_Char  *pBuffer );
     129                 :            : 
     130                 :            :         static sal_Bool parseVMS (
     131                 :            :             FTPDirentry &rEntry,
     132                 :            :             const sal_Char  *pBuffer );
     133                 :            : 
     134                 :            :         static sal_Bool parseUNIX (
     135                 :            :             FTPDirentry &rEntry,
     136                 :            :             const sal_Char  *pBuffer );
     137                 :            : 
     138                 :            : 
     139                 :            :     private:
     140                 :            : 
     141                 :            :         static sal_Bool parseUNIX_isSizeField (
     142                 :            :             const sal_Char *pStart,
     143                 :            :             const sal_Char *pEnd,
     144                 :            :             sal_uInt32     &rSize);
     145                 :            : 
     146                 :            :         static sal_Bool parseUNIX_isMonthField (
     147                 :            :             const sal_Char *pStart,
     148                 :            :             const sal_Char *pEnd,
     149                 :            :             DateTime& rDateTime);
     150                 :            : 
     151                 :            :         static sal_Bool parseUNIX_isDayField (
     152                 :            :             const sal_Char *pStart,
     153                 :            :             const sal_Char *pEnd,
     154                 :            :             DateTime& rDateTime);
     155                 :            : 
     156                 :            :         static sal_Bool parseUNIX_isYearTimeField (
     157                 :            :             const sal_Char *pStart,
     158                 :            :             const sal_Char *pEnd,
     159                 :            :             DateTime& rDateTime);
     160                 :            : 
     161                 :            :         static sal_Bool parseUNIX_isTime (
     162                 :            :             const sal_Char *pStart,
     163                 :            :             const sal_Char *pEnd,
     164                 :            :             sal_uInt16      nHour,
     165                 :            :             DateTime& rDateTime);
     166                 :            : 
     167                 :            :         static sal_Bool setYear (
     168                 :            :             DateTime& rDateTime,
     169                 :            :             sal_uInt16  nYear);
     170                 :            : 
     171                 :            :         static sal_Bool setPath (
     172                 :            :             rtl::OUString& rPath,
     173                 :            :             const sal_Char *value,
     174                 :            :             sal_Int32       length = -1);
     175                 :            :     };
     176                 :            : 
     177                 :            : 
     178                 :            : }
     179                 :            : 
     180                 :            : 
     181                 :            : #endif
     182                 :            : 
     183                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10