From d36ff4d4a020ab1c575f07a86a6b85d4f8264899 Mon Sep 17 00:00:00 2001 From: "mscott%netscape.com" Date: Tue, 30 Jan 2001 05:02:48 +0000 Subject: [PATCH] Bug #63346 --> add methods for reveal and launch to a local file. Stub implementions for OS/2 and Unix right now. r=conrad sr=sspitzer git-svn-id: svn://10.0.0.236/trunk@85736 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/xpcom/io/nsILocalFile.idl | 13 ++++++++ mozilla/xpcom/io/nsLocalFileOS2.cpp | 12 +++++++ mozilla/xpcom/io/nsLocalFileUnix.cpp | 13 ++++++++ mozilla/xpcom/io/nsLocalFileWin.cpp | 48 ++++++++++++++++++++++++++++ 4 files changed, 86 insertions(+) diff --git a/mozilla/xpcom/io/nsILocalFile.idl b/mozilla/xpcom/io/nsILocalFile.idl index 67043e81314..f353a5abb4d 100644 --- a/mozilla/xpcom/io/nsILocalFile.idl +++ b/mozilla/xpcom/io/nsILocalFile.idl @@ -101,6 +101,19 @@ interface nsILocalFile : nsIFile */ attribute string persistentDescriptor; + /** + * reveal --> Ask the operating system to open the folder which contains + * this file or folder. This routine only works on platforms which + * support the ability to open a folder... + */ + void reveal(); + + /** + * launch --> Ask the operating system to attempt to open the file. + * this really just simulates "double clicking" the file on your platform. + * This routine only works on platforms which support this functionality. + */ + void launch(); }; %{C++ diff --git a/mozilla/xpcom/io/nsLocalFileOS2.cpp b/mozilla/xpcom/io/nsLocalFileOS2.cpp index 7455ad1c076..54f68a13796 100644 --- a/mozilla/xpcom/io/nsLocalFileOS2.cpp +++ b/mozilla/xpcom/io/nsLocalFileOS2.cpp @@ -2178,6 +2178,18 @@ nsLocalFile::SetPersistentDescriptor(const char * aPersistentDescriptor) return InitWithPath(aPersistentDescriptor); } +NS_IMETHODIMP +nsLocalFile::Reveal() +{ + return NS_ERROR_FAILURE; +} + + +NS_IMETHODIMP +nsLocalFile::Launch() +{ + return NS_ERROR_FAILURE; +} nsresult NS_NewLocalFile(const char* path, PRBool followLinks, nsILocalFile* *result) diff --git a/mozilla/xpcom/io/nsLocalFileUnix.cpp b/mozilla/xpcom/io/nsLocalFileUnix.cpp index f0b4751f7f9..ce29549d75d 100644 --- a/mozilla/xpcom/io/nsLocalFileUnix.cpp +++ b/mozilla/xpcom/io/nsLocalFileUnix.cpp @@ -1333,6 +1333,19 @@ nsLocalFile::SetPersistentDescriptor(const char *aPersistentDescriptor) return InitWithPath(aPersistentDescriptor); } +NS_IMETHODIMP +nsLocalFile::Reveal() +{ + return NS_ERROR_FAILURE; +} + + +NS_IMETHODIMP +nsLocalFile::Launch() +{ + return NS_ERROR_FAILURE; +} + nsresult NS_NewLocalFile(const char *path, PRBool followSymlinks, nsILocalFile **result) { diff --git a/mozilla/xpcom/io/nsLocalFileWin.cpp b/mozilla/xpcom/io/nsLocalFileWin.cpp index 6c6f774a18b..a35601b7a6e 100644 --- a/mozilla/xpcom/io/nsLocalFileWin.cpp +++ b/mozilla/xpcom/io/nsLocalFileWin.cpp @@ -44,6 +44,7 @@ #include #include +#include "nsXPIDLString.h" #include "prproces.h" // certainly not all the error that can be @@ -1911,6 +1912,53 @@ nsLocalFile::SetPersistentDescriptor(const char * aPersistentDescriptor) return InitWithPath(aPersistentDescriptor); } +NS_IMETHODIMP +nsLocalFile::Reveal() +{ + nsresult rv = NS_OK; + PRBool isDirectory = PR_FALSE; + nsXPIDLCString path; + + IsDirectory(&isDirectory); + if (isDirectory) + { + GetPath(getter_Copies(path)); + } + else + { + nsCOMPtr parent; + GetParent(getter_AddRefs(parent)); + if (parent) + parent->GetPath(getter_Copies(path)); + } + + // use the app registry name to launch a shell execute.... + LONG r = (LONG) ::ShellExecute( NULL, "explore", (const char *) path, NULL, NULL, SW_SHOWNORMAL); + if (r < 32) + rv = NS_ERROR_FAILURE; + else + rv = NS_OK; + + return rv; +} + + +NS_IMETHODIMP +nsLocalFile::Launch() +{ + nsresult rv = NS_OK; + nsXPIDLCString path; + GetPath(getter_Copies(path)); + + // use the app registry name to launch a shell execute.... + LONG r = (LONG) ::ShellExecute( NULL, "open", (const char *) path, NULL, NULL, SW_SHOWNORMAL); + if (r < 32) + rv = NS_ERROR_FAILURE; + else + rv = NS_OK; + + return rv; +} nsresult NS_NewLocalFile(const char* path, PRBool followLinks, nsILocalFile* *result)