2014-05-05 10:30:43 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Implementation of nsIFile for ``Unixy'' systems.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _nsLocalFileUNIX_H_
|
|
|
|
#define _nsLocalFileUNIX_H_
|
|
|
|
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#include "nscore.h"
|
|
|
|
#include "nsString.h"
|
|
|
|
#include "nsReadableUtils.h"
|
|
|
|
#include "nsIHashable.h"
|
2007-07-25 09:53:37 -07:00
|
|
|
#include "nsIClassInfoImpl.h"
|
2012-06-05 16:51:58 -07:00
|
|
|
#include "mozilla/Attributes.h"
|
2011-10-14 08:43:35 -07:00
|
|
|
#ifdef MOZ_WIDGET_COCOA
|
2010-07-21 20:25:24 -07:00
|
|
|
#include "nsILocalFileMac.h"
|
|
|
|
#endif
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2014-05-05 10:30:43 -07:00
|
|
|
/**
|
2007-03-22 10:30:00 -07:00
|
|
|
* we need these for statfs()
|
|
|
|
*/
|
|
|
|
#ifdef HAVE_SYS_STATVFS_H
|
2014-05-05 10:30:43 -07:00
|
|
|
#if defined(__osf__) && defined(__DECCXX)
|
|
|
|
extern "C" int statvfs(const char *, struct statvfs *);
|
|
|
|
#endif
|
|
|
|
#include <sys/statvfs.h>
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_SYS_STATFS_H
|
2014-05-05 10:30:43 -07:00
|
|
|
#include <sys/statfs.h>
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
|
2012-08-29 14:00:10 -07:00
|
|
|
#ifdef HAVE_SYS_VFS_H
|
2014-05-05 10:30:43 -07:00
|
|
|
#include <sys/vfs.h>
|
2012-08-29 14:00:10 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_SYS_MOUNT_H
|
2014-05-05 10:30:43 -07:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/mount.h>
|
2012-08-29 14:00:10 -07:00
|
|
|
#endif
|
|
|
|
|
2012-08-29 14:00:10 -07:00
|
|
|
#if defined(HAVE_STATVFS64) && (!defined(LINUX) && !defined(__osf__))
|
2014-05-05 10:30:43 -07:00
|
|
|
#define STATFS statvfs64
|
|
|
|
#define F_BSIZE f_frsize
|
2012-08-29 14:00:10 -07:00
|
|
|
#elif defined(HAVE_STATVFS) && (!defined(LINUX) && !defined(__osf__))
|
2014-05-05 10:30:43 -07:00
|
|
|
#define STATFS statvfs
|
|
|
|
#define F_BSIZE f_frsize
|
2012-08-29 14:00:10 -07:00
|
|
|
#elif defined(HAVE_STATFS64)
|
2014-05-05 10:30:43 -07:00
|
|
|
#define STATFS statfs64
|
|
|
|
#define F_BSIZE f_bsize
|
2012-08-29 14:00:10 -07:00
|
|
|
#elif defined(HAVE_STATFS)
|
2014-05-05 10:30:43 -07:00
|
|
|
#define STATFS statfs
|
|
|
|
#define F_BSIZE f_bsize
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
|
2013-10-08 23:01:27 -07:00
|
|
|
// stat64 and lstat64 are deprecated on OS X. Normal stat and lstat are
|
|
|
|
// 64-bit by default on OS X 10.6+.
|
|
|
|
#if defined(HAVE_STAT64) && defined(HAVE_LSTAT64) && !defined(XP_MACOSX)
|
2014-05-05 10:30:43 -07:00
|
|
|
#if defined (AIX)
|
|
|
|
#if defined STAT
|
|
|
|
#undef STAT
|
2010-03-14 18:43:16 -07:00
|
|
|
#endif
|
2014-05-05 10:30:43 -07:00
|
|
|
#endif
|
|
|
|
#define STAT stat64
|
|
|
|
#define LSTAT lstat64
|
|
|
|
#define HAVE_STATS64 1
|
2009-04-16 05:09:21 -07:00
|
|
|
#else
|
2014-05-05 10:30:43 -07:00
|
|
|
#define STAT stat
|
|
|
|
#define LSTAT lstat
|
2009-04-16 05:09:21 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2012-06-05 16:51:58 -07:00
|
|
|
class nsLocalFile MOZ_FINAL :
|
2011-10-14 08:43:35 -07:00
|
|
|
#ifdef MOZ_WIDGET_COCOA
|
2014-05-05 10:30:43 -07:00
|
|
|
public nsILocalFileMac,
|
2010-07-21 20:25:24 -07:00
|
|
|
#else
|
2014-05-05 10:30:43 -07:00
|
|
|
public nsILocalFile,
|
2010-07-21 20:25:24 -07:00
|
|
|
#endif
|
2014-05-05 10:30:43 -07:00
|
|
|
public nsIHashable
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
public:
|
2014-05-05 10:30:43 -07:00
|
|
|
NS_DEFINE_STATIC_CID_ACCESSOR(NS_LOCAL_FILE_CID)
|
|
|
|
|
|
|
|
nsLocalFile();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2014-05-05 10:30:43 -07:00
|
|
|
static nsresult nsLocalFileConstructor(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2014-05-05 10:30:43 -07:00
|
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
|
|
|
NS_DECL_NSIFILE
|
|
|
|
NS_DECL_NSILOCALFILE
|
2011-10-14 08:43:35 -07:00
|
|
|
#ifdef MOZ_WIDGET_COCOA
|
2014-05-05 10:30:43 -07:00
|
|
|
NS_DECL_NSILOCALFILEMAC
|
2010-07-21 20:25:24 -07:00
|
|
|
#endif
|
2014-05-05 10:30:43 -07:00
|
|
|
NS_DECL_NSIHASHABLE
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
public:
|
2014-05-05 10:30:43 -07:00
|
|
|
static void GlobalInit();
|
|
|
|
static void GlobalShutdown();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
private:
|
2014-05-05 10:30:43 -07:00
|
|
|
nsLocalFile(const nsLocalFile& other);
|
|
|
|
~nsLocalFile() {}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
protected:
|
2014-05-05 10:30:43 -07:00
|
|
|
// This stat cache holds the *last stat* - it does not invalidate.
|
|
|
|
// Call "FillStatCache" whenever you want to stat our file.
|
|
|
|
struct STAT mCachedStat;
|
|
|
|
nsCString mPath;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2014-05-05 10:30:43 -07:00
|
|
|
void LocateNativeLeafName(nsACString::const_iterator &,
|
|
|
|
nsACString::const_iterator &);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2014-05-05 10:30:43 -07:00
|
|
|
nsresult CopyDirectoryTo(nsIFile *newParent);
|
|
|
|
nsresult CreateAllAncestors(uint32_t permissions);
|
|
|
|
nsresult GetNativeTargetPathName(nsIFile *newParent,
|
|
|
|
const nsACString &newName,
|
|
|
|
nsACString &_retval);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2014-05-05 10:30:43 -07:00
|
|
|
bool FillStatCache();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2014-05-05 10:30:43 -07:00
|
|
|
nsresult CreateAndKeepOpen(uint32_t type, int flags,
|
|
|
|
uint32_t permissions, PRFileDesc **_retval);
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* _nsLocalFileUNIX_H_ */
|