winGetFolder.h
Go to the documentation of this file.
1 /*
2  Originally from /xpcom/io/SpecialSystemDirectory.cpp
3  (with changeset http://hg.mozilla.org/mozilla-central/rev/09f7d5c32f3a
4  removed because we don't have to handle this case)
5 */
6 
7 /* ***** BEGIN LICENSE BLOCK *****
8  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
9  *
10  * The contents of this file are subject to the Mozilla Public License Version
11  * 1.1 (the "License"); you may not use this file except in compliance with
12  * the License. You may obtain a copy of the License at
13  * http://www.mozilla.org/MPL/
14  *
15  * Software distributed under the License is distributed on an "AS IS" basis,
16  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
17  * for the specific language governing rights and limitations under the
18  * License.
19  *
20  * The Original Code is Mozilla Communicator client code, released
21  * March 31, 1998.
22  *
23  * The Initial Developer of the Original Code is
24  * Netscape Communications Corporation.
25  * Portions created by the Initial Developer are Copyright (C) 1998
26  * the Initial Developer. All Rights Reserved.
27  *
28  * Contributor(s):
29  * Doug Turner <dougt@netscape.com>
30  * IBM Corp.
31  * Fredrik Holmqvist <thesuckiestemail@yahoo.se>
32  * Jungshik Shin <jshin@i18nl10n.com>
33  *
34  * Alternatively, the contents of this file may be used under the terms of
35  * either of the GNU General Public License Version 2 or later (the "GPL"),
36  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
37  * in which case the provisions of the GPL or the LGPL are applicable instead
38  * of those above. If you wish to allow use of your version of this file only
39  * under the terms of either the GPL or the LGPL, and not to allow others to
40  * use your version of this file under the terms of the MPL, indicate your
41  * decision by deleting the provisions above and replace them with the notice
42  * and other provisions required by the GPL or the LGPL. If you do not delete
43  * the provisions above, a recipient may use your version of this file under
44  * the terms of any one of the MPL, the GPL or the LGPL.
45  *
46  * ***** END LICENSE BLOCK ***** */
47 
48 static nsresult GetWindowsFolder(int folder, nsILocalFile** aFile)
49 {
50 #ifdef WINCE
51 #define SHGetSpecialFolderPathW SHGetSpecialFolderPath
52 #endif
53 
54  WCHAR path[MAX_PATH + 2];
55  HRESULT result = SHGetSpecialFolderPathW(NULL, path, folder, true);
56 
57  if (!SUCCEEDED(result))
58  return NS_ERROR_FAILURE;
59 
60  // Append the trailing slash
61  int len = wcslen(path);
62  if (len > 1 && path[len - 1] != L'\\')
63  {
64  path[len] = L'\\';
65  path[++len] = L'\0';
66  }
67 
68  return NS_NewLocalFile(nsDependentString(path, len), PR_TRUE, aFile);
69 }
static nsresult GetWindowsFolder(int folder, nsILocalFile **aFile)
Definition: winGetFolder.h:48