Back to index

lightning-sunbird  0.9+nobinonly
nsWinAPIs.h
Go to the documentation of this file.
00001 /* ***** BEGIN LICENSE BLOCK *****
00002  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00003  *
00004  * The contents of this file are subject to the Mozilla Public License Version
00005  * 1.1 (the "License"); you may not use this file except in compliance with
00006  * the License. You may obtain a copy of the License at
00007  * http://www.mozilla.org/MPL/
00008  *
00009  * Software distributed under the License is distributed on an "AS IS" basis,
00010  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00011  * for the specific language governing rights and limitations under the
00012  * License.
00013  *
00014  * The Original Code is mozilla.org code.
00015  *
00016  * The Initial Developer of the Original Code is Jungshik Shin
00017  * <jshin@i18nl10n.com>.  Portions created by the Initial Developer
00018  * are Copyright (C) 2006 the Initial Developer. All Rights Reserved.
00019  *
00020  * Contributor(s):
00021  *
00022  * Alternatively, the contents of this file may be used under the terms of
00023  * either the GNU General Public License Version 2 or later (the "GPL"), or
00024  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00025  * in which case the provisions of the GPL or the LGPL are applicable instead
00026  * of those above. If you wish to allow use of your version of this file only
00027  * under the terms of either the GPL or the LGPL, and not to allow others to
00028  * use your version of this file under the terms of the MPL, indicate your
00029  * decision by deleting the provisions above and replace them with the notice
00030  * and other provisions required by the GPL or the LGPL. If you do not delete
00031  * the provisions above, a recipient may use your version of this file under
00032  * the terms of any one of the MPL, the GPL or the LGPL.
00033  *
00034  * ***** END LICENSE BLOCK ***** */
00035 
00036 #ifndef nsWinAPIs_h__
00037 #define nsWinAPIs_h__
00038 
00039 #include "prtypes.h"
00040 #include <windows.h>
00041 #include <shellapi.h>
00042 #include <shlobj.h>
00043 
00044 typedef BOOL (WINAPI * nsSHGetPathFromIDList) (LPCITEMIDLIST pidList, LPWSTR pszPath);
00045 typedef UINT (WINAPI * nsGetSystemDirectory) (LPWSTR lpBuffer, UINT usize);
00046 typedef UINT (WINAPI * nsGetWindowsDirectory) (LPWSTR lpBuffer, UINT usize);
00047 typedef DWORD (WINAPI * nsGetTempPath) (DWORD len, LPWSTR lpBuffer);
00048 typedef DWORD (WINAPI * nsGetEnvironmentVariable) (LPCWSTR lpName, LPWSTR lpBuffer, DWORD nSize);
00049 typedef BOOL (WINAPI * nsCreateDirectory) (LPCWSTR aDir,
00050                                            LPSECURITY_ATTRIBUTES aSecAttr);
00051 typedef HANDLE (WINAPI * nsCreateFile) (LPCWSTR aPath, DWORD aAccess,
00052                                         DWORD aMode, 
00053                                         LPSECURITY_ATTRIBUTES aSecAttr,
00054                                         DWORD aCreat, DWORD aFlags,
00055                                         HANDLE aTemplate);
00056 typedef HINSTANCE (WINAPI * nsShellExecute) (HWND hwnd, LPCWSTR lpOperation,
00057                                              LPCWSTR lpFile,
00058                                              LPCWSTR lpParameters,
00059                                              LPCWSTR lpDirectory,
00060                                              INT nShowCmd);
00061 typedef BOOL (WINAPI * nsCopyFile) (LPCWSTR aSrc, LPCWSTR aDest, BOOL aNoOverwrite);
00062 typedef BOOL (WINAPI * nsMoveFile) (LPCWSTR aSrc, LPCWSTR aDest);
00063 typedef BOOL (WINAPI * nsGetFileVersionInfo) (LPCWSTR aPath, DWORD aHandle, DWORD aLen,
00064                                               LPVOID aData);
00065 typedef DWORD (WINAPI * nsGetFileVersionInfoSize) (LPCWSTR aPath, LPDWORD aHandle);
00066 typedef DWORD (WINAPI * nsGetFileAttributes) (LPCWSTR aPath);
00067 typedef BOOL (WINAPI * nsGetFileAttributesEx) (LPCWSTR aPath, GET_FILEEX_INFO_LEVELS aLevel,
00068                                                LPVOID aInfo);
00069 typedef BOOL (WINAPI * nsGetFileAttributesExA) (LPCSTR aPath, GET_FILEEX_INFO_LEVELS aLevel,
00070                                                 LPVOID aInfo);
00071 typedef DWORD (WINAPI * nsGetShortPathName) (LPCWSTR aLPATH, LPWSTR aSPATH, DWORD aLen);
00072 typedef BOOL (WINAPI * nsGetDiskFreeSpace) (LPCWSTR aDir, LPDWORD aSpC, 
00073                                             LPDWORD aBpS, LPDWORD aNFC, LPDWORD aTNC);
00074 typedef BOOL (WINAPI * nsGetDiskFreeSpaceEx) (LPCWSTR aDir, 
00075                                               PULARGE_INTEGER aFBA,
00076                                               PULARGE_INTEGER aTNB,
00077                                               PULARGE_INTEGER aTNFB);
00078 typedef DWORD (WINAPI * nsGetModuleFileName) (HMODULE aModule, LPWSTR aName, DWORD aSize);
00079 
00080 typedef wchar_t* (*nsGetCwd) (wchar_t *buffer, int maxlen);
00081 typedef wchar_t* (*nsGetDCwd) (int aDrive, wchar_t *aPath, int aMaxLen);
00082 typedef FILE* (*nsFopen) (const wchar_t *aName, const wchar_t *aMode);
00083 typedef int (*nsRemove) (const wchar_t *aPath);
00084 typedef int (*nsRmdir) (const wchar_t *aPath);
00085 typedef int (*nsChmod) (const wchar_t *aName, int pmode);
00086 
00087 class nsWinAPIs {
00088 
00089 public: 
00090     static nsSHGetPathFromIDList      mSHGetPathFromIDList;
00091     static nsGetSystemDirectory       mGetSystemDirectory;
00092     static nsGetWindowsDirectory      mGetWindowsDirectory;
00093     static nsGetTempPath              mGetTempPath;
00094     static nsGetEnvironmentVariable   mGetEnvironmentVariable;
00095     static nsCreateDirectory          mCreateDirectory;
00096     static nsCreateFile               mCreateFile;
00097     static nsShellExecute             mShellExecute;
00098     static nsCopyFile                 mCopyFile;
00099     static nsMoveFile                 mMoveFile;
00100     static nsGetFileVersionInfo       mGetFileVersionInfo;
00101     static nsGetFileVersionInfoSize   mGetFileVersionInfoSize;
00102     static nsGetFileAttributes        mGetFileAttributes;
00103     static nsGetFileAttributesEx      mGetFileAttributesEx;
00104     static nsGetFileAttributesExA     mGetFileAttributesExA;
00105     static nsGetShortPathName         mGetShortPathName;    
00106     static nsGetDiskFreeSpace         mGetDiskFreeSpace;     
00107     static nsGetDiskFreeSpaceEx       mGetDiskFreeSpaceEx;     
00108     static nsGetModuleFileName        mGetModuleFileName;
00109 
00110 
00111     static nsGetCwd                   mGetCwd;
00112     static nsFopen                    mFopen;
00113     static nsGetDCwd                  mGetDCwd;
00114     static nsRemove                   mRemove;
00115     static nsRmdir                    mRmdir;
00116     static nsChmod                    mChmod;
00117 
00118 private:
00119     nsWinAPIs() {}
00120     static PRBool GlobalInit(); 
00121     static PRBool sUseUnicode; 
00122     friend NS_COM PRBool NS_UseUnicode();
00123     friend NS_COM void NS_StartupWinAPIs();
00124 
00125     // a dummy variable to make sure that |GlobalInit| is invoked
00126     // before the first use |nsLocalFileWin| that relies on Windows APIs 
00127     // set up in |GlobalInit|
00128     static PRBool sDummy;
00129 };
00130 
00131 NS_COM PRBool NS_UseUnicode();
00132 
00133 #endif