[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677

sullivan sullivan at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 05:57:28 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit d5ef5c6f9e9e59722f8f1c7e836d7c264628bc72
Author: sullivan <sullivan at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Mar 14 22:36:50 2002 +0000

    	Made history store its data in ~/Library/Application Support/<app name>/History.plist
    
    	* History.subproj/IFWebHistoryPrivate.m:
    	(GetRefPath), (FindFolderPath): Functions copied from NSSavePanel.m for using
    	FindFolder in a POSIX sort of way. Ken plans to put some version of this in
    	IFNSFileManagerExtensions eventually, which I'll switch to later.
    	(-[IFWebHistoryPrivate historyFilePath]): Construct the path using FindFolderPath
    	and the file name.
    	(-[IFWebHistoryPrivate loadHistory]),
    	(-[IFWebHistoryPrivate saveHistory]): failure case debug messages are now more specific.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@740 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index 528dde4..43b461f 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,16 @@
+2002-03-14  John Sullivan  <sullivan at apple.com>
+
+	Made history store its data in ~/Library/Application Support/<app name>/History.plist
+
+	* History.subproj/IFWebHistoryPrivate.m: 
+	(GetRefPath), (FindFolderPath): Functions copied from NSSavePanel.m for using
+	FindFolder in a POSIX sort of way. Ken plans to put some version of this in
+	IFNSFileManagerExtensions eventually, which I'll switch to later.
+	(-[IFWebHistoryPrivate historyFilePath]): Construct the path using FindFolderPath
+	and the file name.
+	(-[IFWebHistoryPrivate loadHistory]),
+	(-[IFWebHistoryPrivate saveHistory]): failure case debug messages are now more specific.
+
 2002-03-13  Richard Williamson  <rjw at apple.com>
 
         Added support to stop plugins in removeFromSuperview.
diff --git a/WebKit/ChangeLog-2002-12-03 b/WebKit/ChangeLog-2002-12-03
index 528dde4..43b461f 100644
--- a/WebKit/ChangeLog-2002-12-03
+++ b/WebKit/ChangeLog-2002-12-03
@@ -1,3 +1,16 @@
+2002-03-14  John Sullivan  <sullivan at apple.com>
+
+	Made history store its data in ~/Library/Application Support/<app name>/History.plist
+
+	* History.subproj/IFWebHistoryPrivate.m: 
+	(GetRefPath), (FindFolderPath): Functions copied from NSSavePanel.m for using
+	FindFolder in a POSIX sort of way. Ken plans to put some version of this in
+	IFNSFileManagerExtensions eventually, which I'll switch to later.
+	(-[IFWebHistoryPrivate historyFilePath]): Construct the path using FindFolderPath
+	and the file name.
+	(-[IFWebHistoryPrivate loadHistory]),
+	(-[IFWebHistoryPrivate saveHistory]): failure case debug messages are now more specific.
+
 2002-03-13  Richard Williamson  <rjw at apple.com>
 
         Added support to stop plugins in removeFromSuperview.
diff --git a/WebKit/History.subproj/IFWebHistoryPrivate.m b/WebKit/History.subproj/IFWebHistoryPrivate.m
index 8d16b9f..669039e 100644
--- a/WebKit/History.subproj/IFWebHistoryPrivate.m
+++ b/WebKit/History.subproj/IFWebHistoryPrivate.m
@@ -259,37 +259,110 @@
     return arrayRep;
 }
 
+static NSString* GetRefPath(FSRef* ref)
+{
+    // This function was cribbed from NSSavePanel.m
+    CFURLRef    url  = CFURLCreateFromFSRef((CFAllocatorRef)NULL, ref);
+    CFStringRef path = CFURLCopyFileSystemPath(url, kCFURLPOSIXPathStyle);
+    CFRelease(url);
+    return [(NSString*)path autorelease];
+}
+
+static NSString* FindFolderPath(OSType domainType, OSType folderType)
+{
+    // create URL from FSRef. Then get path string in our POSIX style that we so know and love
+    // This function was cribbed from NSSavePanel.m, 'cept the createFolder parameter flopped.
+    FSRef     folderRef;
+    if (FSFindFolder(domainType, folderType, YES /*createFolder*/, &folderRef) == noErr) {
+        return GetRefPath(&folderRef);
+    } else {
+        return nil;
+    }
+}
+
 - (NSString *)historyFilePath
 {
-    // FIXME: put this somewhere sensible
-    return @"/tmp/alexander.history";
+    NSFileManager *fileManager;
+    NSString *applicationSupportDirectoryPath;
+    NSString *appName;
+    NSString *appInAppSupportPath;
+    BOOL fileExists;
+    BOOL isDirectory;
+
+    // FIXME: Ken's going to put the equivalent of FindFolderPath in IFNSFileManagerExtensions; use
+    // that when it's available and delete the previous two functions.
+    applicationSupportDirectoryPath = FindFolderPath(kUserDomain, kApplicationSupportFolderType);
+    if (applicationSupportDirectoryPath == nil) {
+        WEBKITDEBUG("FindFolderPath(kUserDomain, kApplicationSupportFolderType) failed\n");
+        return nil;
+    }
+
+    appName = [[[NSBundle mainBundle] infoDictionary] objectForKey: (NSString *)kCFBundleExecutableKey];
+    if (appName == nil) {
+        WEBKITDEBUG("Couldn't get application name using kCFBundleExecutableKey\n");
+        return nil;
+    }
+
+    appInAppSupportPath = [applicationSupportDirectoryPath stringByAppendingPathComponent: appName];
+    fileManager = [NSFileManager defaultManager];
+    fileExists = [fileManager fileExistsAtPath: appInAppSupportPath isDirectory: &isDirectory];
+    if (fileExists && !isDirectory) {
+        WEBKITDEBUG1("Non-directory file exists at %s\n", DEBUG_OBJECT(appInAppSupportPath));
+        return nil;
+    } else if (!fileExists && ![fileManager createDirectoryAtPath: appInAppSupportPath attributes: nil]) {
+        WEBKITDEBUG1("Couldn't create directory %s\n", DEBUG_OBJECT(appInAppSupportPath));
+        return nil;
+    }
+
+    return [appInAppSupportPath stringByAppendingPathComponent: @"History.plist"];
 }
 
 - (void)loadHistory
 {
-    NSString *path = [self historyFilePath];
-    NSArray *array = [NSArray arrayWithContentsOfFile: path];
+    NSString *path;
+    NSArray *array;
+    int index, count;
+    
+    path = [self historyFilePath];
+    if (path == nil) {
+        WEBKITDEBUG("couldn't load history; couldn't find or create directory to store it in\n");
+        return;
+    }
 
+    array = [NSArray arrayWithContentsOfFile: path];
     if (array == nil) {
-        WEBKITDEBUG1("attempt to read history from %s failed", DEBUG_OBJECT(path));
-    } else {
-        int index, count;
-
-        count = [array count];
-        for (index = 0; index < count; ++index) {
-            IFURIEntry *entry = [[IFURIEntry alloc] initFromDictionaryRepresentation: [array objectAtIndex: index]];
-            [self addEntry: entry];
+        if (![[NSFileManager defaultManager] fileExistsAtPath: path]) {
+            WEBKITDEBUG1("no history file found at %s\n",
+                         DEBUG_OBJECT(path));
+        } else {
+            WEBKITDEBUG1("attempt to read history from %s failed; perhaps contents are corrupted\n",
+                         DEBUG_OBJECT(path));
         }
+        return;
+    }
+
+    count = [array count];
+    for (index = 0; index < count; ++index) {
+        IFURIEntry *entry = [[IFURIEntry alloc] initFromDictionaryRepresentation:
+            [array objectAtIndex: index]];
+        [self addEntry: entry];
     }
 }
 
 - (void)saveHistory
 {
-    NSString *path = [self historyFilePath];
-    NSArray *array = [self arrayRepresentation];
-    
+    NSString *path;
+    NSArray *array;
+
+    path = [self historyFilePath];
+    if (path == nil) {
+        WEBKITDEBUG("couldn't save history; couldn't find or create directory to store it in\n");
+        return;
+    }
+
+    array = [self arrayRepresentation];
     if (![array writeToFile:path atomically:NO]) {
-        WEBKITDEBUG2("attempt to save %s to %s failed", DEBUG_OBJECT(array), DEBUG_OBJECT(path));
+        WEBKITDEBUG2("attempt to save %s to %s failed\n", DEBUG_OBJECT(array), DEBUG_OBJECT(path));
     }
 }
 
diff --git a/WebKit/History.subproj/WebHistoryPrivate.m b/WebKit/History.subproj/WebHistoryPrivate.m
index 8d16b9f..669039e 100644
--- a/WebKit/History.subproj/WebHistoryPrivate.m
+++ b/WebKit/History.subproj/WebHistoryPrivate.m
@@ -259,37 +259,110 @@
     return arrayRep;
 }
 
+static NSString* GetRefPath(FSRef* ref)
+{
+    // This function was cribbed from NSSavePanel.m
+    CFURLRef    url  = CFURLCreateFromFSRef((CFAllocatorRef)NULL, ref);
+    CFStringRef path = CFURLCopyFileSystemPath(url, kCFURLPOSIXPathStyle);
+    CFRelease(url);
+    return [(NSString*)path autorelease];
+}
+
+static NSString* FindFolderPath(OSType domainType, OSType folderType)
+{
+    // create URL from FSRef. Then get path string in our POSIX style that we so know and love
+    // This function was cribbed from NSSavePanel.m, 'cept the createFolder parameter flopped.
+    FSRef     folderRef;
+    if (FSFindFolder(domainType, folderType, YES /*createFolder*/, &folderRef) == noErr) {
+        return GetRefPath(&folderRef);
+    } else {
+        return nil;
+    }
+}
+
 - (NSString *)historyFilePath
 {
-    // FIXME: put this somewhere sensible
-    return @"/tmp/alexander.history";
+    NSFileManager *fileManager;
+    NSString *applicationSupportDirectoryPath;
+    NSString *appName;
+    NSString *appInAppSupportPath;
+    BOOL fileExists;
+    BOOL isDirectory;
+
+    // FIXME: Ken's going to put the equivalent of FindFolderPath in IFNSFileManagerExtensions; use
+    // that when it's available and delete the previous two functions.
+    applicationSupportDirectoryPath = FindFolderPath(kUserDomain, kApplicationSupportFolderType);
+    if (applicationSupportDirectoryPath == nil) {
+        WEBKITDEBUG("FindFolderPath(kUserDomain, kApplicationSupportFolderType) failed\n");
+        return nil;
+    }
+
+    appName = [[[NSBundle mainBundle] infoDictionary] objectForKey: (NSString *)kCFBundleExecutableKey];
+    if (appName == nil) {
+        WEBKITDEBUG("Couldn't get application name using kCFBundleExecutableKey\n");
+        return nil;
+    }
+
+    appInAppSupportPath = [applicationSupportDirectoryPath stringByAppendingPathComponent: appName];
+    fileManager = [NSFileManager defaultManager];
+    fileExists = [fileManager fileExistsAtPath: appInAppSupportPath isDirectory: &isDirectory];
+    if (fileExists && !isDirectory) {
+        WEBKITDEBUG1("Non-directory file exists at %s\n", DEBUG_OBJECT(appInAppSupportPath));
+        return nil;
+    } else if (!fileExists && ![fileManager createDirectoryAtPath: appInAppSupportPath attributes: nil]) {
+        WEBKITDEBUG1("Couldn't create directory %s\n", DEBUG_OBJECT(appInAppSupportPath));
+        return nil;
+    }
+
+    return [appInAppSupportPath stringByAppendingPathComponent: @"History.plist"];
 }
 
 - (void)loadHistory
 {
-    NSString *path = [self historyFilePath];
-    NSArray *array = [NSArray arrayWithContentsOfFile: path];
+    NSString *path;
+    NSArray *array;
+    int index, count;
+    
+    path = [self historyFilePath];
+    if (path == nil) {
+        WEBKITDEBUG("couldn't load history; couldn't find or create directory to store it in\n");
+        return;
+    }
 
+    array = [NSArray arrayWithContentsOfFile: path];
     if (array == nil) {
-        WEBKITDEBUG1("attempt to read history from %s failed", DEBUG_OBJECT(path));
-    } else {
-        int index, count;
-
-        count = [array count];
-        for (index = 0; index < count; ++index) {
-            IFURIEntry *entry = [[IFURIEntry alloc] initFromDictionaryRepresentation: [array objectAtIndex: index]];
-            [self addEntry: entry];
+        if (![[NSFileManager defaultManager] fileExistsAtPath: path]) {
+            WEBKITDEBUG1("no history file found at %s\n",
+                         DEBUG_OBJECT(path));
+        } else {
+            WEBKITDEBUG1("attempt to read history from %s failed; perhaps contents are corrupted\n",
+                         DEBUG_OBJECT(path));
         }
+        return;
+    }
+
+    count = [array count];
+    for (index = 0; index < count; ++index) {
+        IFURIEntry *entry = [[IFURIEntry alloc] initFromDictionaryRepresentation:
+            [array objectAtIndex: index]];
+        [self addEntry: entry];
     }
 }
 
 - (void)saveHistory
 {
-    NSString *path = [self historyFilePath];
-    NSArray *array = [self arrayRepresentation];
-    
+    NSString *path;
+    NSArray *array;
+
+    path = [self historyFilePath];
+    if (path == nil) {
+        WEBKITDEBUG("couldn't save history; couldn't find or create directory to store it in\n");
+        return;
+    }
+
+    array = [self arrayRepresentation];
     if (![array writeToFile:path atomically:NO]) {
-        WEBKITDEBUG2("attempt to save %s to %s failed", DEBUG_OBJECT(array), DEBUG_OBJECT(path));
+        WEBKITDEBUG2("attempt to save %s to %s failed\n", DEBUG_OBJECT(array), DEBUG_OBJECT(path));
     }
 }
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list