Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: third_party/sqlite/mac_time_machine.patch

Issue 6990066: Mac TimeMachine File Exclusions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 Index: src/sqliteInt.h
2 ===================================================================
3 --- src/sqliteInt.h (revision 87306)
4 +++ src/sqliteInt.h (working copy)
5 @@ -2522,6 +2522,16 @@
6 #endif
7
8 /*
9 +** The CoreServices.h and CoreFoundation.h headers are needed for excluding a
10 +** -journal file from Time Machine backups when its associated database has
11 +** previously been excluded by the client code.
12 +*/
13 +#if defined(__APPLE__)
14 +#include <CoreServices/CoreServices.h>
15 +#include <CoreFoundation/CoreFoundation.h>
16 +#endif
17 +
18 +/*
19 ** The following macros mimic the standard library functions toupper(),
20 ** isspace(), isalnum(), isdigit() and isxdigit(), respectively. The
21 ** sqlite versions only work for ASCII characters, regardless of locale.
22 Index: src/pager.c
23 ===================================================================
24 --- src/pager.c (revision 87306)
25 +++ src/pager.c (working copy)
26 @@ -5130,7 +5130,21 @@
27 }
28 }
29
30 +#if defined(__APPLE__)
31 /*
32 +** Create and return a CFURLRef given a cstring containing the path to a file.
33 +*/
34 +static CFURLRef create_cfurl_from_cstring(const char* filePath){
35 + CFStringRef urlString = CFStringCreateWithFileSystemRepresentation(
36 + kCFAllocatorDefault, filePath);
37 + CFURLRef urlRef = CFURLCreateWithFileSystemPath(kCFAllocatorDefault,
38 + urlString, kCFURLPOSIXPathStyle, FALSE);
39 + CFRelease(urlString);
40 + return urlRef;
41 +}
42 +#endif
43 +
44 +/*
45 ** This function is called at the start of every write transaction.
46 ** There must already be a RESERVED or EXCLUSIVE lock on the database
47 ** file when this routine is called.
48 @@ -5189,6 +5203,21 @@
49 #else
50 rc = sqlite3OsOpen(pVfs, pPager->zJournal, pPager->jfd, flags, 0);
51 #endif
52 +#if defined(__APPLE__)
53 + /* Set the TimeMachine exclusion metadata for the journal if it has
54 + ** been set for the database. */
55 + if( rc==SQLITE_OK && pPager->zFilename!=NULL
56 + && strlen(pPager->zFilename)>0 ){
57 + CFURLRef database = create_cfurl_from_cstring(pPager->zFilename);
58 + if( CSBackupIsItemExcluded(database, NULL) ){
59 + CFURLRef journal = create_cfurl_from_cstring(pPager->zJournal);
60 + /* Ignore errors from the following exclusion call. */
61 + CSBackupSetItemExcluded(journal, TRUE, FALSE);
62 + CFRelease(journal);
63 + }
64 + CFRelease(database);
65 + }
66 +#endif
67 }
68 assert( rc!=SQLITE_OK || isOpen(pPager->jfd) );
69 }
70 Index: ext/fts3/fts3_porter.c
71 ===================================================================
72 --- ext/fts3/fts3_porter.c (revision 87306)
73 +++ ext/fts3/fts3_porter.c (working copy)
74 @@ -129,7 +129,7 @@
75 /*
76 ** Vowel or consonant
77 */
78 -static const char cType[] = {
79 +static const char vOrCType[] = {
80 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0,
81 1, 1, 1, 2, 1
82 };
83 @@ -153,7 +153,7 @@
84 char x = *z;
85 if( x==0 ) return 0;
86 assert( x>='a' && x<='z' );
87 - j = cType[x-'a'];
88 + j = vOrCType[x-'a'];
89 if( j<2 ) return j;
90 return z[1]==0 || isVowel(z + 1);
91 }
92 @@ -162,7 +162,7 @@
93 char x = *z;
94 if( x==0 ) return 0;
95 assert( x>='a' && x<='z' );
96 - j = cType[x-'a'];
97 + j = vOrCType[x-'a'];
98 if( j<2 ) return 1-j;
99 return isConsonant(z + 1);
100 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698