nsLocalFile.h revision e1e952b2c8602177899424e8022cabc03b372b7a
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync/* ***** BEGIN LICENSE BLOCK *****
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * Version: MPL 1.1/GPL 2.0/LGPL 2.1
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync *
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * The contents of this file are subject to the Mozilla Public License Version
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * 1.1 (the "License"); you may not use this file except in compliance with
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * the License. You may obtain a copy of the License at
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * http://www.mozilla.org/MPL/
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync *
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * Software distributed under the License is distributed on an "AS IS" basis,
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * for the specific language governing rights and limitations under the
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * License.
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync *
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * The Original Code is Mozilla Communicator client code, released
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * March 31, 1998.
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync *
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * The Initial Developer of the Original Code is
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * Netscape Communications Corporation.
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * Portions created by the Initial Developer are Copyright (C) 1998-1999
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * the Initial Developer. All Rights Reserved.
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync *
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * Contributor(s):
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync *
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * Alternatively, the contents of this file may be used under the terms of
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * either of the GNU General Public License Version 2 or later (the "GPL"),
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * in which case the provisions of the GPL or the LGPL are applicable instead
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * of those above. If you wish to allow use of your version of this file only
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * under the terms of either the GPL or the LGPL, and not to allow others to
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * use your version of this file under the terms of the MPL, indicate your
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * decision by deleting the provisions above and replace them with the notice
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * and other provisions required by the GPL or the LGPL. If you do not delete
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * the provisions above, a recipient may use your version of this file under
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * the terms of any one of the MPL, the GPL or the LGPL.
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync *
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * ***** END LICENSE BLOCK *****
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync *
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * This Original Code has been modified by IBM Corporation. Modifications made by IBM
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * described herein are Copyright (c) International Business Machines Corporation, 2000.
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * Modifications to Mozilla code or documentation identified per MPL Section 3.3
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync *
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * Date Modified by Description of modification
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync * 04/20/2000 IBM Corp. OS/2 build.
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync */
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync#ifndef _NS_LOCAL_FILE_H_
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync#define _NS_LOCAL_FILE_H_
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync#define NS_LOCAL_FILE_CID {0x2e23e220, 0x60be, 0x11d3, {0x8c, 0x4a, 0x00, 0x00, 0x64, 0x65, 0x73, 0x74}}
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync#define NS_DECL_NSLOCALFILE_UNICODE_METHODS \
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync nsresult AppendUnicode(const PRUnichar *aNode); \
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync nsresult GetUnicodeLeafName(PRUnichar **aLeafName); \
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync nsresult SetUnicodeLeafName(const PRUnichar *aLeafName); \
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync nsresult CopyToUnicode(nsIFile *aNewParentDir, const PRUnichar *aNewLeafName); \
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync nsresult CopyToFollowingLinksUnicode(nsIFile *aNewParentDir, const PRUnichar *aNewLeafName); \
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync nsresult MoveToUnicode(nsIFile *aNewParentDir, const PRUnichar *aNewLeafName); \
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync nsresult GetUnicodeTarget(PRUnichar **aTarget); \
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync nsresult GetUnicodePath(PRUnichar **aPath); \
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync nsresult InitWithUnicodePath(const PRUnichar *aPath); \
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync nsresult AppendRelativeUnicodePath(const PRUnichar *aRelativePath);
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync// nsXPComInit needs to know about how we are implemented,
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync// so here we will export it. Other users should not depend
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync// on this.
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync#include <errno.h>
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync#include "nsILocalFile.h"
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync#ifdef XP_WIN
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync#include "nsLocalFileWin.h"
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync#elif defined(XP_MACOSX) && (!defined(VBOX) || !defined(RT_ARCH_AMD64))
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync#include "nsLocalFileOSX.h"
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync#elif defined(XP_MAC)
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync#include "nsLocalFileMac.h"
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync#elif defined(L4ENV)
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync /* Major hack attack!!! */
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync#include "nsLocalFileL4.h"
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync#elif defined(XP_UNIX) || defined(XP_BEOS)
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync#include "nsLocalFileUnix.h"
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync#elif defined(XP_OS2)
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync#include "nsLocalFileOS2.h"
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync#else
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync#error NOT_IMPLEMENTED
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync#endif
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync#define NSRESULT_FOR_RETURN(ret) (((ret) < 0) ? NSRESULT_FOR_ERRNO() : NS_OK)
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncinline nsresult
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncnsresultForErrno(int err)
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync{
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync switch (err) {
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync case 0:
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync return NS_OK;
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync case ENOENT:
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync return NS_ERROR_FILE_TARGET_DOES_NOT_EXIST;
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync case ENOTDIR:
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync return NS_ERROR_FILE_DESTINATION_NOT_DIR;
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync#ifdef ENOLINK
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync case ENOLINK:
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync return NS_ERROR_FILE_UNRESOLVABLE_SYMLINK;
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync#endif /* ENOLINK */
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync case EEXIST:
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync return NS_ERROR_FILE_ALREADY_EXISTS;
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync#ifdef EPERM
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync case EPERM:
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync#endif /* EPERM */
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync case EACCES:
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync return NS_ERROR_FILE_ACCESS_DENIED;
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync default:
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync return NS_ERROR_FAILURE;
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync }
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync}
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync#define NSRESULT_FOR_ERRNO() nsresultForErrno(errno)
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncvoid NS_StartupLocalFile();
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncvoid NS_ShutdownLocalFile();
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync#endif
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync