51 #include <nsAutoPtr.h>
52 #include <nsComponentManagerUtils.h>
53 #include <nsILocalFile.h>
55 #include <nsStringGlue.h>
81 #define MAXPATHLEN PATH_MAX
82 #elif defined(MAX_PATH)
83 #define MAXPATHLEN MAX_PATH
84 #elif defined(_MAX_PATH)
85 #define MAXPATHLEN _MAX_PATH
86 #elif defined(CCHMAXPATH)
87 #define MAXPATHLEN CCHMAXPATH
89 #define MAXPATHLEN 1024
122 NS_ENSURE_ARG_POINTER(aCurrentDir);
128 nsCOMPtr<nsILocalFile> currentDir;
130 WCHAR currentDirPath[MAX_PATH];
131 NS_ENSURE_TRUE(_wgetcwd(currentDirPath, NS_ARRAY_LENGTH(currentDirPath)),
133 rv = NS_NewLocalFile(nsDependentString(currentDirPath),
135 getter_AddRefs(currentDir));
136 NS_ENSURE_SUCCESS(rv, rv);
139 NS_ENSURE_TRUE(getcwd(currentDirPath, NS_ARRAY_LENGTH(currentDirPath)),
141 rv = NS_NewNativeLocalFile(nsDependentCString(currentDirPath),
143 getter_AddRefs(currentDir));
144 NS_ENSURE_SUCCESS(rv, rv);
148 rv = CallQueryInterface(currentDir, aCurrentDir);
149 NS_ENSURE_SUCCESS(rv, rv);
155 sbFileUtils::SetCurrentDir(nsIFile* aCurrentDir)
158 NS_ENSURE_ARG_POINTER(aCurrentDir);
164 nsAutoString currentDirPath;
165 rv = aCurrentDir->GetPath(currentDirPath);
166 NS_ENSURE_SUCCESS(rv, rv);
170 NS_ENSURE_FALSE(_wchdir(currentDirPath.get()), NS_ERROR_FAILURE);
172 NS_ENSURE_FALSE(chdir(NS_ConvertUTF16toUTF8(currentDirPath).
get()),
180 sbFileUtils::GetExactPath(
const nsAString& aFilePath, nsAString& aExactPath)
183 aExactPath.Truncate();
187 nsAutoArrayPtr<WCHAR> shortPath = NULL;
188 nsAutoArrayPtr<WCHAR> longPath = NULL;
190 length = ::GetShortPathNameW(aFilePath.BeginReading(),
193 if (length == 0)
return NS_OK;
196 shortPath =
new WCHAR[length];
197 length = ::GetShortPathNameW(aFilePath.BeginReading(),
200 if (length == 0)
return NS_OK;
204 length = ::GetLongPathNameW(shortPath,
207 if (length == 0)
return NS_OK;
211 longPath =
new WCHAR[length];
212 length = ::GetLongPathNameW(shortPath,
215 if (length == 0)
return NS_OK;
217 aExactPath.Assign(longPath);
NS_IMPL_THREADSAFE_ISUPPORTS1(sbDeviceCapsCompatibility, sbIDeviceCapsCompatibility) sbDeviceCapsCompatibility
NS_DECL_ISUPPORTS NS_DECL_SBIFILEUTILS sbFileUtils()