| OLD | NEW |
| 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 // vfs - pointer to the sqlite3_vfs object. | 47 // vfs - pointer to the sqlite3_vfs object. |
| 48 // fileName - the name of the file. | 48 // fileName - the name of the file. |
| 49 // id - the structure that will manipulate the newly opened file. | 49 // id - the structure that will manipulate the newly opened file. |
| 50 // desiredFlags - the desired open mode flags. | 50 // desiredFlags - the desired open mode flags. |
| 51 // usedFlags - the actual open mode flags that were used. | 51 // usedFlags - the actual open mode flags that were used. |
| 52 int chromiumOpen(sqlite3_vfs*, | 52 int chromiumOpen(sqlite3_vfs*, |
| 53 const char* fileName, | 53 const char* fileName, |
| 54 sqlite3_file* id, | 54 sqlite3_file* id, |
| 55 int desiredFlags, | 55 int desiredFlags, |
| 56 int* usedFlags) { | 56 int* usedFlags) { |
| 57 HANDLE h = | 57 HANDLE h = Platform::current()->databaseOpenFile(String::fromUTF8(fileName), |
| 58 Platform::current()->databaseOpenFile(String(fileName), desiredFlags); | 58 desiredFlags); |
| 59 if (h == INVALID_HANDLE_VALUE) { | 59 if (h == INVALID_HANDLE_VALUE) { |
| 60 if (desiredFlags & SQLITE_OPEN_READWRITE) { | 60 if (desiredFlags & SQLITE_OPEN_READWRITE) { |
| 61 int newFlags = | 61 int newFlags = |
| 62 (desiredFlags | SQLITE_OPEN_READONLY) & ~SQLITE_OPEN_READWRITE; | 62 (desiredFlags | SQLITE_OPEN_READONLY) & ~SQLITE_OPEN_READWRITE; |
| 63 return chromiumOpen(0, fileName, id, newFlags, usedFlags); | 63 return chromiumOpen(0, fileName, id, newFlags, usedFlags); |
| 64 } else | 64 } else |
| 65 return SQLITE_CANTOPEN; | 65 return SQLITE_CANTOPEN; |
| 66 } | 66 } |
| 67 if (usedFlags) { | 67 if (usedFlags) { |
| 68 if (desiredFlags & SQLITE_OPEN_READWRITE) | 68 if (desiredFlags & SQLITE_OPEN_READWRITE) |
| 69 *usedFlags = SQLITE_OPEN_READWRITE; | 69 *usedFlags = SQLITE_OPEN_READWRITE; |
| 70 else | 70 else |
| 71 *usedFlags = SQLITE_OPEN_READONLY; | 71 *usedFlags = SQLITE_OPEN_READONLY; |
| 72 } | 72 } |
| 73 | 73 |
| 74 chromium_sqlite3_initialize_win_sqlite3_file(id, h); | 74 chromium_sqlite3_initialize_win_sqlite3_file(id, h); |
| 75 return SQLITE_OK; | 75 return SQLITE_OK; |
| 76 } | 76 } |
| 77 | 77 |
| 78 // Deletes the given file. | 78 // Deletes the given file. |
| 79 // | 79 // |
| 80 // vfs - pointer to the sqlite3_vfs object. | 80 // vfs - pointer to the sqlite3_vfs object. |
| 81 // fileName - the name of the file. | 81 // fileName - the name of the file. |
| 82 // syncDir - determines if the directory to which this file belongs | 82 // syncDir - determines if the directory to which this file belongs |
| 83 // should be synched after the file is deleted. | 83 // should be synched after the file is deleted. |
| 84 int chromiumDelete(sqlite3_vfs*, const char* fileName, int) { | 84 int chromiumDelete(sqlite3_vfs*, const char* fileName, int) { |
| 85 return Platform::current()->databaseDeleteFile(String(fileName), false); | 85 return Platform::current()->databaseDeleteFile(String::fromUTF8(fileName), |
| 86 false); |
| 86 } | 87 } |
| 87 | 88 |
| 88 // Check the existance and status of the given file. | 89 // Check the existance and status of the given file. |
| 89 // | 90 // |
| 90 // vfs - pointer to the sqlite3_vfs object. | 91 // vfs - pointer to the sqlite3_vfs object. |
| 91 // fileName - the name of the file. | 92 // fileName - the name of the file. |
| 92 // flag - the type of test to make on this file. | 93 // flag - the type of test to make on this file. |
| 93 // res - the result. | 94 // res - the result. |
| 94 int chromiumAccess(sqlite3_vfs*, const char* fileName, int flag, int* res) { | 95 int chromiumAccess(sqlite3_vfs*, const char* fileName, int flag, int* res) { |
| 95 DWORD attr = Platform::current()->databaseGetFileAttributes(String(fileName)); | 96 DWORD attr = Platform::current()->databaseGetFileAttributes( |
| 97 String::fromUTF8(fileName)); |
| 96 switch (flag) { | 98 switch (flag) { |
| 97 case SQLITE_ACCESS_READ: | 99 case SQLITE_ACCESS_READ: |
| 98 case SQLITE_ACCESS_EXISTS: | 100 case SQLITE_ACCESS_EXISTS: |
| 99 *res = (attr != INVALID_FILE_ATTRIBUTES); | 101 *res = (attr != INVALID_FILE_ATTRIBUTES); |
| 100 break; | 102 break; |
| 101 case SQLITE_ACCESS_READWRITE: | 103 case SQLITE_ACCESS_READWRITE: |
| 102 *res = ((attr & FILE_ATTRIBUTE_READONLY) == 0); | 104 *res = ((attr & FILE_ATTRIBUTE_READONLY) == 0); |
| 103 break; | 105 break; |
| 104 default: | 106 default: |
| 105 return SQLITE_ERROR; | 107 return SQLITE_ERROR; |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 chromiumDlSym, | 188 chromiumDlSym, |
| 187 chromiumDlClose, | 189 chromiumDlClose, |
| 188 chromiumRandomness, | 190 chromiumRandomness, |
| 189 chromiumSleep, | 191 chromiumSleep, |
| 190 chromiumCurrentTime, | 192 chromiumCurrentTime, |
| 191 chromiumGetLastError}; | 193 chromiumGetLastError}; |
| 192 sqlite3_vfs_register(&chromium_vfs, 0); | 194 sqlite3_vfs_register(&chromium_vfs, 0); |
| 193 } | 195 } |
| 194 | 196 |
| 195 } // namespace blink | 197 } // namespace blink |
| OLD | NEW |