1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "nsDependentString.h"
12 // Load the path of a file saved with SaveFileToEnv
13 already_AddRefed
<nsIFile
> GetFileFromEnv(const char* name
) {
15 nsCOMPtr
<nsIFile
> file
;
18 WCHAR path
[_MAX_PATH
];
19 if (!GetEnvironmentVariableW(NS_ConvertASCIItoUTF16(name
).get(), path
,
23 rv
= NS_NewLocalFile(nsDependentString(path
), true, getter_AddRefs(file
));
24 if (NS_FAILED(rv
)) return nullptr;
28 const char* arg
= PR_GetEnv(name
);
33 rv
= NS_NewNativeLocalFile(nsDependentCString(arg
), true,
34 getter_AddRefs(file
));
43 } // namespace mozilla