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

Side by Side Diff: third_party/WebKit/Source/modules/webdatabase/sqlite/SQLiteFileSystemPosix.cpp

Issue 2634473002: [websql] Filenames are utf-8, not latin1. (Closed)
Patch Set: final changes? Created 3 years, 11 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 pBuf, iAmt, iOfst); 82 pBuf, iAmt, iOfst);
83 } 83 }
84 84
85 int chromiumTruncate(sqlite3_file* sqliteFile, sqlite3_int64 size) { 85 int chromiumTruncate(sqlite3_file* sqliteFile, sqlite3_int64 size) {
86 chromiumVfsFile* chromiumFile = 86 chromiumVfsFile* chromiumFile =
87 reinterpret_cast<chromiumVfsFile*>(sqliteFile); 87 reinterpret_cast<chromiumVfsFile*>(sqliteFile);
88 88
89 // The OSX and Linux sandboxes block ftruncate(), proxy to the browser 89 // The OSX and Linux sandboxes block ftruncate(), proxy to the browser
90 // process. 90 // process.
91 if (Platform::current()->databaseSetFileSize( 91 if (Platform::current()->databaseSetFileSize(
92 String(chromiumFile->wrappedFileName), size)) 92 String::fromUTF8(chromiumFile->wrappedFileName), size))
93 return SQLITE_OK; 93 return SQLITE_OK;
94 return SQLITE_IOERR_TRUNCATE; 94 return SQLITE_IOERR_TRUNCATE;
95 } 95 }
96 96
97 int chromiumSync(sqlite3_file* sqliteFile, int flags) { 97 int chromiumSync(sqlite3_file* sqliteFile, int flags) {
98 chromiumVfsFile* chromiumFile = 98 chromiumVfsFile* chromiumFile =
99 reinterpret_cast<chromiumVfsFile*>(sqliteFile); 99 reinterpret_cast<chromiumVfsFile*>(sqliteFile);
100 return chromiumFile->wrappedFile->pMethods->xSync(chromiumFile->wrappedFile, 100 return chromiumFile->wrappedFile->pMethods->xSync(chromiumFile->wrappedFile,
101 flags); 101 flags);
102 } 102 }
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 // vfs - pointer to the sqlite3_vfs object. 155 // vfs - pointer to the sqlite3_vfs object.
156 // fileName - the name of the file. 156 // fileName - the name of the file.
157 // id - the structure that will manipulate the newly opened file. 157 // id - the structure that will manipulate the newly opened file.
158 // desiredFlags - the desired open mode flags. 158 // desiredFlags - the desired open mode flags.
159 // usedFlags - the actual open mode flags that were used. 159 // usedFlags - the actual open mode flags that were used.
160 int chromiumOpenInternal(sqlite3_vfs* vfs, 160 int chromiumOpenInternal(sqlite3_vfs* vfs,
161 const char* fileName, 161 const char* fileName,
162 sqlite3_file* id, 162 sqlite3_file* id,
163 int desiredFlags, 163 int desiredFlags,
164 int* usedFlags) { 164 int* usedFlags) {
165 int fd = 165 int fd = Platform::current()->databaseOpenFile(String::fromUTF8(fileName),
166 Platform::current()->databaseOpenFile(String(fileName), desiredFlags); 166 desiredFlags);
167 if ((fd < 0) && (desiredFlags & SQLITE_OPEN_READWRITE)) { 167 if ((fd < 0) && (desiredFlags & SQLITE_OPEN_READWRITE)) {
168 desiredFlags = 168 desiredFlags =
169 (desiredFlags & ~(SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE)) | 169 (desiredFlags & ~(SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE)) |
170 SQLITE_OPEN_READONLY; 170 SQLITE_OPEN_READONLY;
171 fd = Platform::current()->databaseOpenFile(String(fileName), desiredFlags); 171 fd = Platform::current()->databaseOpenFile(String::fromUTF8(fileName),
172 desiredFlags);
172 } 173 }
173 if (fd < 0) 174 if (fd < 0)
174 return SQLITE_CANTOPEN; 175 return SQLITE_CANTOPEN;
175 176
176 if (usedFlags) 177 if (usedFlags)
177 *usedFlags = desiredFlags; 178 *usedFlags = desiredFlags;
178 179
179 fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC); 180 fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC);
180 181
181 // The mask 0x00007F00 gives us the 7 bits that determine the type of the file 182 // The mask 0x00007F00 gives us the 7 bits that determine the type of the file
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 return SQLITE_OK; 241 return SQLITE_OK;
241 } 242 }
242 243
243 // Deletes the given file. 244 // Deletes the given file.
244 // 245 //
245 // vfs - pointer to the sqlite3_vfs object. 246 // vfs - pointer to the sqlite3_vfs object.
246 // fileName - the name of the file. 247 // fileName - the name of the file.
247 // syncDir - determines if the directory to which this file belongs 248 // syncDir - determines if the directory to which this file belongs
248 // should be synched after the file is deleted. 249 // should be synched after the file is deleted.
249 int chromiumDelete(sqlite3_vfs*, const char* fileName, int syncDir) { 250 int chromiumDelete(sqlite3_vfs*, const char* fileName, int syncDir) {
250 return Platform::current()->databaseDeleteFile(String(fileName), syncDir); 251 return Platform::current()->databaseDeleteFile(String::fromUTF8(fileName),
252 syncDir);
251 } 253 }
252 254
253 // Check the existance and status of the given file. 255 // Check the existance and status of the given file.
254 // 256 //
255 // vfs - pointer to the sqlite3_vfs object. 257 // vfs - pointer to the sqlite3_vfs object.
256 // fileName - the name of the file. 258 // fileName - the name of the file.
257 // flag - the type of test to make on this file. 259 // flag - the type of test to make on this file.
258 // res - the result. 260 // res - the result.
259 int chromiumAccess(sqlite3_vfs*, const char* fileName, int flag, int* res) { 261 int chromiumAccess(sqlite3_vfs*, const char* fileName, int flag, int* res) {
260 int attr = static_cast<int>( 262 int attr = static_cast<int>(Platform::current()->databaseGetFileAttributes(
261 Platform::current()->databaseGetFileAttributes(String(fileName))); 263 String::fromUTF8(fileName)));
262 if (attr < 0) { 264 if (attr < 0) {
263 *res = 0; 265 *res = 0;
264 return SQLITE_OK; 266 return SQLITE_OK;
265 } 267 }
266 268
267 switch (flag) { 269 switch (flag) {
268 case SQLITE_ACCESS_EXISTS: 270 case SQLITE_ACCESS_EXISTS:
269 *res = 1; // if the file doesn't exist, attr < 0 271 *res = 1; // if the file doesn't exist, attr < 0
270 break; 272 break;
271 case SQLITE_ACCESS_READWRITE: 273 case SQLITE_ACCESS_READWRITE:
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 chromiumDlSym, 361 chromiumDlSym,
360 chromiumDlClose, 362 chromiumDlClose,
361 chromiumRandomness, 363 chromiumRandomness,
362 chromiumSleep, 364 chromiumSleep,
363 chromiumCurrentTime, 365 chromiumCurrentTime,
364 chromiumGetLastError}; 366 chromiumGetLastError};
365 sqlite3_vfs_register(&chromium_vfs, 0); 367 sqlite3_vfs_register(&chromium_vfs, 0);
366 } 368 }
367 369
368 } // namespace blink 370 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698