LCOV - code coverage report
Current view: directory - xpcom/io - nsLocalFileUnix.h (source / functions) Found Hit Coverage
Test: app.info Lines: 1 1 100.0 %
Date: 2012-06-02 Functions: 1 1 100.0 %

       1                 : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 : /* ***** BEGIN LICENSE BLOCK *****
       3                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       4                 :  *
       5                 :  * The contents of this file are subject to the Mozilla Public License Version
       6                 :  * 1.1 (the "License"); you may not use this file except in compliance with
       7                 :  * the License. You may obtain a copy of the License at
       8                 :  * http://www.mozilla.org/MPL/
       9                 :  *
      10                 :  * Software distributed under the License is distributed on an "AS IS" basis,
      11                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      12                 :  * for the specific language governing rights and limitations under the
      13                 :  * License.
      14                 :  *
      15                 :  * The Original Code is Mozilla Communicator client code, released
      16                 :  * March 31, 1998.
      17                 :  *
      18                 :  * The Initial Developer of the Original Code is
      19                 :  * Netscape Communications Corporation.
      20                 :  * Portions created by the Initial Developer are Copyright (C) 1998-1999
      21                 :  * the Initial Developer. All Rights Reserved.
      22                 :  *
      23                 :  * Contributor(s):
      24                 :  *   Mike Shaver <shaver@mozilla.org>
      25                 :  *
      26                 :  * Alternatively, the contents of this file may be used under the terms of
      27                 :  * either of the GNU General Public License Version 2 or later (the "GPL"),
      28                 :  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      29                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      30                 :  * of those above. If you wish to allow use of your version of this file only
      31                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      32                 :  * use your version of this file under the terms of the MPL, indicate your
      33                 :  * decision by deleting the provisions above and replace them with the notice
      34                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      35                 :  * the provisions above, a recipient may use your version of this file under
      36                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      37                 :  *
      38                 :  * ***** END LICENSE BLOCK ***** */
      39                 : 
      40                 : /*
      41                 :  * Implementation of nsIFile for ``Unixy'' systems.
      42                 :  */
      43                 : 
      44                 : #ifndef _nsLocalFileUNIX_H_
      45                 : #define _nsLocalFileUNIX_H_
      46                 : 
      47                 : #include <sys/stat.h>
      48                 : #include <sys/types.h>
      49                 : #include <unistd.h>
      50                 : 
      51                 : #include "nscore.h"
      52                 : #include "nsString.h"
      53                 : #include "nsReadableUtils.h"
      54                 : #include "nsIHashable.h"
      55                 : #include "nsIClassInfoImpl.h"
      56                 : #ifdef MOZ_WIDGET_COCOA
      57                 : #include "nsILocalFileMac.h"
      58                 : #endif
      59                 : 
      60                 : /** 
      61                 :  *  we need these for statfs()
      62                 :  */
      63                 : #ifdef HAVE_SYS_STATVFS_H
      64                 :     #if defined(__osf__) && defined(__DECCXX)
      65                 :         extern "C" int statvfs(const char *, struct statvfs *);
      66                 :     #endif
      67                 :     #include <sys/statvfs.h>
      68                 : #endif
      69                 : 
      70                 : #ifdef HAVE_SYS_STATFS_H
      71                 :     #include <sys/statfs.h>
      72                 : #endif
      73                 : 
      74                 : #if defined(XP_MACOSX) && (defined(HAVE_STATVFS64) || !defined(HAVE_STATVFS))
      75                 : #error "Double-check which members of the 'STATFS' struct we're using!"
      76                 : #endif
      77                 : 
      78                 : #ifdef HAVE_STATVFS64
      79                 :     #define STATFS statvfs64
      80                 : #else
      81                 :     #ifdef HAVE_STATVFS
      82                 :         #define STATFS statvfs
      83                 :     #else
      84                 :         #define STATFS statfs
      85                 :     #endif
      86                 : #endif
      87                 : 
      88                 : // so we can statfs on freebsd
      89                 : #if defined(__FreeBSD__)
      90                 :     #define HAVE_SYS_STATFS_H
      91                 :     #define STATFS statfs
      92                 :     #include <sys/param.h>
      93                 :     #include <sys/mount.h>
      94                 : #endif
      95                 : 
      96                 : #if defined(HAVE_STAT64) && defined(HAVE_LSTAT64)
      97                 :     #if defined (AIX)
      98                 :         #if defined STAT
      99                 :             #undef STAT
     100                 :         #endif
     101                 :     #endif
     102                 :     #define STAT stat64
     103                 :     #define LSTAT lstat64
     104                 :     #define HAVE_STATS64 1
     105                 : #else
     106                 :     #define STAT stat
     107                 :     #define LSTAT lstat
     108                 : #endif
     109                 : 
     110                 : 
     111                 : class nsLocalFile :
     112                 : #ifdef MOZ_WIDGET_COCOA
     113                 :                            public nsILocalFileMac,
     114                 : #else
     115                 :                            public nsILocalFile,
     116                 : #endif
     117                 :                            public nsIHashable
     118                 : {
     119                 : public:
     120                 :     NS_DEFINE_STATIC_CID_ACCESSOR(NS_LOCAL_FILE_CID)
     121                 :     
     122                 :     nsLocalFile();
     123                 : 
     124                 :     static nsresult nsLocalFileConstructor(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr);
     125                 : 
     126                 :     NS_DECL_ISUPPORTS
     127                 :     NS_DECL_NSIFILE
     128                 :     NS_DECL_NSILOCALFILE
     129                 : #ifdef MOZ_WIDGET_COCOA
     130                 :     NS_DECL_NSILOCALFILEMAC
     131                 : #endif
     132                 :     NS_DECL_NSIHASHABLE
     133                 : 
     134                 : public:
     135                 :     static void GlobalInit();
     136                 :     static void GlobalShutdown();
     137                 : 
     138                 : private:
     139                 :     nsLocalFile(const nsLocalFile& other);
     140          797259 :     ~nsLocalFile() {}
     141                 : 
     142                 : protected:
     143                 :     // This stat cache holds the *last stat* - it does not invalidate.
     144                 :     // Call "FillStatCache" whenever you want to stat our file.
     145                 :     struct STAT  mCachedStat;
     146                 :     nsCString    mPath;
     147                 : 
     148                 :     void LocateNativeLeafName(nsACString::const_iterator &,
     149                 :                               nsACString::const_iterator &);
     150                 : 
     151                 :     nsresult CopyDirectoryTo(nsIFile *newParent);
     152                 :     nsresult CreateAllAncestors(PRUint32 permissions);
     153                 :     nsresult GetNativeTargetPathName(nsIFile *newParent,
     154                 :                                      const nsACString &newName,
     155                 :                                      nsACString &_retval);
     156                 : 
     157                 :     bool FillStatCache();
     158                 : 
     159                 :     nsresult CreateAndKeepOpen(PRUint32 type, PRIntn flags,
     160                 :                                PRUint32 permissions, PRFileDesc **_retval);
     161                 : };
     162                 : 
     163                 : #endif /* _nsLocalFileUNIX_H_ */

Generated by: LCOV version 1.7