Back to index

lightning-sunbird  0.9+nobinonly
nsLocalFile.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is Mozilla Communicator client code, released
00016  * March 31, 1998.
00017  *
00018  * The Initial Developer of the Original Code is
00019  * Netscape Communications Corporation.
00020  * Portions created by the Initial Developer are Copyright (C) 1998-1999
00021  * the Initial Developer. All Rights Reserved.
00022  *
00023  * Contributor(s):
00024  *
00025  * Alternatively, the contents of this file may be used under the terms of
00026  * either of the GNU General Public License Version 2 or later (the "GPL"),
00027  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00028  * in which case the provisions of the GPL or the LGPL are applicable instead
00029  * of those above. If you wish to allow use of your version of this file only
00030  * under the terms of either the GPL or the LGPL, and not to allow others to
00031  * use your version of this file under the terms of the MPL, indicate your
00032  * decision by deleting the provisions above and replace them with the notice
00033  * and other provisions required by the GPL or the LGPL. If you do not delete
00034  * the provisions above, a recipient may use your version of this file under
00035  * the terms of any one of the MPL, the GPL or the LGPL.
00036  *
00037  * ***** END LICENSE BLOCK *****
00038  *
00039  * This Original Code has been modified by IBM Corporation. Modifications made by IBM 
00040  * described herein are Copyright (c) International Business Machines Corporation, 2000.
00041  * Modifications to Mozilla code or documentation identified per MPL Section 3.3
00042  *
00043  * Date             Modified by     Description of modification
00044  * 04/20/2000       IBM Corp.      OS/2 build.
00045  */
00046 
00047 #ifndef _NS_LOCAL_FILE_H_
00048 #define _NS_LOCAL_FILE_H_
00049 
00050 #define NS_LOCAL_FILE_CID {0x2e23e220, 0x60be, 0x11d3, {0x8c, 0x4a, 0x00, 0x00, 0x64, 0x65, 0x73, 0x74}}
00051 
00052 #define NS_DECL_NSLOCALFILE_UNICODE_METHODS                                                      \
00053     nsresult AppendUnicode(const PRUnichar *aNode);                                              \
00054     nsresult GetUnicodeLeafName(PRUnichar **aLeafName);                                          \
00055     nsresult SetUnicodeLeafName(const PRUnichar *aLeafName);                                     \
00056     nsresult CopyToUnicode(nsIFile *aNewParentDir, const PRUnichar *aNewLeafName);               \
00057     nsresult CopyToFollowingLinksUnicode(nsIFile *aNewParentDir, const PRUnichar *aNewLeafName); \
00058     nsresult MoveToUnicode(nsIFile *aNewParentDir, const PRUnichar *aNewLeafName);               \
00059     nsresult GetUnicodeTarget(PRUnichar **aTarget);                                              \
00060     nsresult GetUnicodePath(PRUnichar **aPath);                                                  \
00061     nsresult InitWithUnicodePath(const PRUnichar *aPath);                                        \
00062     nsresult AppendRelativeUnicodePath(const PRUnichar *aRelativePath);
00063 
00064 // nsXPComInit needs to know about how we are implemented,
00065 // so here we will export it.  Other users should not depend
00066 // on this.
00067 
00068 #include <errno.h>
00069 #include "nsILocalFile.h"
00070 
00071 #ifdef XP_WIN
00072 #include "nsLocalFileWin.h"
00073 #elif defined(XP_MACOSX)
00074 #include "nsLocalFileOSX.h"
00075 #elif defined(XP_MAC)
00076 #include "nsLocalFileMac.h"
00077 #elif defined(XP_UNIX) || defined(XP_BEOS)
00078 #include "nsLocalFileUnix.h"
00079 #elif defined(XP_OS2)
00080 #include "nsLocalFileOS2.h"
00081 #else
00082 #error NOT_IMPLEMENTED
00083 #endif
00084 
00085 #define NSRESULT_FOR_RETURN(ret) (((ret) < 0) ? NSRESULT_FOR_ERRNO() : NS_OK)
00086 
00087 inline nsresult
00088 nsresultForErrno(int err)
00089 {
00090     switch (err) {
00091       case 0:
00092         return NS_OK;
00093       case ENOENT:
00094         return NS_ERROR_FILE_TARGET_DOES_NOT_EXIST;
00095       case ENOTDIR:
00096         return NS_ERROR_FILE_DESTINATION_NOT_DIR;
00097 #ifdef ENOLINK
00098       case ENOLINK:
00099         return NS_ERROR_FILE_UNRESOLVABLE_SYMLINK;
00100 #endif /* ENOLINK */
00101       case EEXIST:
00102         return NS_ERROR_FILE_ALREADY_EXISTS;
00103 #ifdef EPERM
00104       case EPERM:
00105 #endif /* EPERM */
00106       case EACCES:
00107         return NS_ERROR_FILE_ACCESS_DENIED;
00108       /*
00109        * On AIX 4.3, ENOTEMPTY is defined as EEXIST,
00110        * so there can't be cases for both without
00111        * preprocessing.
00112        */
00113 #if ENOTEMPTY != EEXIST
00114       case ENOTEMPTY:
00115         return NS_ERROR_FILE_DIR_NOT_EMPTY;
00116 #endif /* ENOTEMPTY != EEXIST */
00117       default:
00118         return NS_ERROR_FAILURE;
00119     }
00120 }
00121 
00122 #define NSRESULT_FOR_ERRNO() nsresultForErrno(errno)
00123 
00124 void NS_StartupLocalFile();
00125 void NS_ShutdownLocalFile();
00126 
00127 #endif