forked from mirrors/gecko-dev
Bug 1890352 - Add OS Documents folder to nsIDirectoryService. r=xpcom-reviewers,nika
Differential Revision: https://phabricator.services.mozilla.com/D209586
This commit is contained in:
parent
8037e2bb55
commit
dbd654fa89
5 changed files with 17 additions and 7 deletions
|
|
@ -2465,6 +2465,7 @@ STATIC_ATOMS = [
|
|||
Atom("DirectoryService_OS_SystemConfigDir", "SysConfD"),
|
||||
# Atom("DirectoryService_OS_HomeDirectory", "Home"), # "Home" is present above
|
||||
Atom("DirectoryService_OS_DesktopDirectory", "Desk"),
|
||||
Atom("DirectoryService_OS_DocumentsDirectory", "Docs"),
|
||||
Atom("DirectoryService_InitCurrentProcess_dummy", "MozBinD"),
|
||||
Atom("DirectoryService_SystemDirectory", "SysD"),
|
||||
Atom("DirectoryService_UserLibDirectory", "ULibDir"),
|
||||
|
|
|
|||
|
|
@ -94,7 +94,6 @@ static nsresult GetWindowsFolder(int aFolder, nsIFile** aFile) {
|
|||
return NS_NewLocalFile(nsDependentString(path, len), true, aFile);
|
||||
}
|
||||
|
||||
# if defined(MOZ_THUNDERBIRD) || defined(MOZ_SUITE)
|
||||
/*
|
||||
* Return the default save-to location for the Windows Library passed in
|
||||
* through aFolderId.
|
||||
|
|
@ -122,7 +121,6 @@ static nsresult GetLibrarySaveToPath(int aFallbackFolderId,
|
|||
|
||||
return GetWindowsFolder(aFallbackFolderId, aFile);
|
||||
}
|
||||
# endif
|
||||
|
||||
/**
|
||||
* Provides a fallback for getting the path to APPDATA or LOCALAPPDATA by
|
||||
|
|
@ -527,6 +525,9 @@ nsresult GetSpecialSystemDirectory(SystemDirectories aSystemSystemDirectory,
|
|||
case Mac_UserDesktopDirectory: {
|
||||
return GetOSXFolderType(kUserDomain, kDesktopFolderType, aFile);
|
||||
}
|
||||
case Mac_UserDocumentsDirectory: {
|
||||
return GetOSXFolderType(kUserDomain, kDocumentsFolderType, aFile);
|
||||
}
|
||||
case Mac_LocalApplicationsDirectory: {
|
||||
return GetOSXFolderType(kLocalDomain, kApplicationsFolderType, aFile);
|
||||
}
|
||||
|
|
@ -674,12 +675,10 @@ nsresult GetSpecialSystemDirectory(SystemDirectories aSystemSystemDirectory,
|
|||
}
|
||||
return rv;
|
||||
}
|
||||
# if defined(MOZ_THUNDERBIRD) || defined(MOZ_SUITE)
|
||||
case Win_Documents: {
|
||||
return GetLibrarySaveToPath(CSIDL_MYDOCUMENTS, FOLDERID_DocumentsLibrary,
|
||||
aFile);
|
||||
}
|
||||
# endif
|
||||
#endif // XP_WIN
|
||||
|
||||
#if defined(XP_UNIX)
|
||||
|
|
@ -687,6 +686,7 @@ nsresult GetSpecialSystemDirectory(SystemDirectories aSystemSystemDirectory,
|
|||
return GetUnixHomeDir(aFile);
|
||||
|
||||
case Unix_XDG_Desktop:
|
||||
case Unix_XDG_Documents:
|
||||
case Unix_XDG_Download:
|
||||
return GetUnixXDGUserDirectory(aSystemSystemDirectory, aFile);
|
||||
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ enum SystemDirectories {
|
|||
Mac_UserPreferencesDirectory = 107,
|
||||
Mac_PictureDocumentsDirectory = 108,
|
||||
Mac_DefaultScreenshotDirectory = 109,
|
||||
Mac_UserDocumentsDirectory = 110,
|
||||
|
||||
Win_SystemDirectory = 201,
|
||||
Win_WindowsDirectory = 202,
|
||||
|
|
@ -42,14 +43,13 @@ enum SystemDirectories {
|
|||
Win_LocalAppdata = 224,
|
||||
Win_ProgramFiles = 225,
|
||||
Win_Downloads = 226,
|
||||
#if defined(MOZ_THUNDERBIRD) || defined(MOZ_SUITE)
|
||||
Win_Documents = 228,
|
||||
#endif
|
||||
|
||||
Unix_HomeDirectory = 303,
|
||||
Unix_XDG_Desktop = 304,
|
||||
Unix_XDG_Documents = 305,
|
||||
Unix_XDG_Download = 306,
|
||||
Unix_SystemConfigDirectory = 307
|
||||
Unix_SystemConfigDirectory = 307,
|
||||
};
|
||||
|
||||
nsresult GetSpecialSystemDirectory(SystemDirectories aSystemSystemDirectory,
|
||||
|
|
|
|||
|
|
@ -367,6 +367,9 @@ nsDirectoryService::GetFile(const char* aProp, bool* aPersistent,
|
|||
} else if (inAtom == nsGkAtoms::DirectoryService_OS_DesktopDirectory) {
|
||||
rv = GetSpecialSystemDirectory(Mac_UserDesktopDirectory,
|
||||
getter_AddRefs(localFile));
|
||||
} else if (inAtom == nsGkAtoms::DirectoryService_OS_DocumentsDirectory) {
|
||||
rv = GetSpecialSystemDirectory(Mac_UserDocumentsDirectory,
|
||||
getter_AddRefs(localFile));
|
||||
} else if (inAtom == nsGkAtoms::DirectoryService_LocalApplicationsDirectory) {
|
||||
rv = GetSpecialSystemDirectory(Mac_LocalApplicationsDirectory,
|
||||
getter_AddRefs(localFile));
|
||||
|
|
@ -399,6 +402,8 @@ nsDirectoryService::GetFile(const char* aProp, bool* aPersistent,
|
|||
} else if (inAtom == nsGkAtoms::DirectoryService_OS_DesktopDirectory) {
|
||||
rv = GetSpecialSystemDirectory(Win_Desktopdirectory,
|
||||
getter_AddRefs(localFile));
|
||||
} else if (inAtom == nsGkAtoms::DirectoryService_OS_DocumentsDirectory) {
|
||||
rv = GetSpecialSystemDirectory(Win_Documents, getter_AddRefs(localFile));
|
||||
} else if (inAtom == nsGkAtoms::DirectoryService_Appdata) {
|
||||
rv = GetSpecialSystemDirectory(Win_Appdata, getter_AddRefs(localFile));
|
||||
} else if (inAtom == nsGkAtoms::DirectoryService_LocalAppdata) {
|
||||
|
|
@ -422,6 +427,9 @@ nsDirectoryService::GetFile(const char* aProp, bool* aPersistent,
|
|||
} else if (inAtom == nsGkAtoms::DirectoryService_OS_SystemConfigDir) {
|
||||
rv = GetSpecialSystemDirectory(Unix_SystemConfigDirectory,
|
||||
getter_AddRefs(localFile));
|
||||
} else if (inAtom == nsGkAtoms::DirectoryService_OS_DocumentsDirectory) {
|
||||
rv = GetSpecialSystemDirectory(Unix_XDG_Documents,
|
||||
getter_AddRefs(localFile));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@
|
|||
* if there is one, otherwise it's just the same as "Home"
|
||||
*/
|
||||
#define NS_OS_DESKTOP_DIR "Desk"
|
||||
#define NS_OS_DOCUMENTS_DIR "Docs"
|
||||
|
||||
#define NS_OS_DEFAULT_DOWNLOAD_DIR "DfltDwnld"
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue