OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 function errorHandler(error) | 239 function errorHandler(error) |
240 { | 240 { |
241 var errorMessage = WebInspector.IsolatedFileSystem.errorMessage(erro
r); | 241 var errorMessage = WebInspector.IsolatedFileSystem.errorMessage(erro
r); |
242 console.error(errorMessage + " when setting content for file '" + (t
his._path + "/" + path) + "'"); | 242 console.error(errorMessage + " when setting content for file '" + (t
his._path + "/" + path) + "'"); |
243 callback(); | 243 callback(); |
244 } | 244 } |
245 }, | 245 }, |
246 | 246 |
247 /** | 247 /** |
248 * @param {string} path | 248 * @param {string} path |
249 * @param {string} content | 249 * @param {string} newName |
250 * @param {function(boolean, string=)} callback | 250 * @param {function(boolean, string=)} callback |
251 */ | 251 */ |
252 renameFile: function(path, newName, callback) | 252 renameFile: function(path, newName, callback) |
253 { | 253 { |
254 newName = newName ? newName.trim() : newName; | 254 newName = newName ? newName.trim() : newName; |
255 if (!newName || newName.indexOf("/") !== -1) { | 255 if (!newName || newName.indexOf("/") !== -1) { |
256 callback(false); | 256 callback(false); |
257 return; | 257 return; |
258 } | 258 } |
259 var fileEntry; | 259 var fileEntry; |
(...skipping 17 matching lines...) Expand all Loading... |
277 if (entry.name === newName) { | 277 if (entry.name === newName) { |
278 callback(false); | 278 callback(false); |
279 return; | 279 return; |
280 } | 280 } |
281 | 281 |
282 fileEntry = entry; | 282 fileEntry = entry; |
283 fileEntry.getParent(dirEntryLoaded, errorHandler.bind(this)); | 283 fileEntry.getParent(dirEntryLoaded, errorHandler.bind(this)); |
284 } | 284 } |
285 | 285 |
286 /** | 286 /** |
287 * @param {DirectoryEntry} entry | 287 * @param {Entry} entry |
288 */ | 288 */ |
289 function dirEntryLoaded(entry) | 289 function dirEntryLoaded(entry) |
290 { | 290 { |
291 dirEntry = entry; | 291 dirEntry = entry; |
292 dirEntry.getFile(newName, null, newFileEntryLoaded, newFileEntryLoad
ErrorHandler); | 292 dirEntry.getFile(newName, null, newFileEntryLoaded, newFileEntryLoad
ErrorHandler); |
293 } | 293 } |
294 | 294 |
295 /** | 295 /** |
296 * @param {FileEntry} entry | 296 * @param {FileEntry} entry |
297 */ | 297 */ |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 } | 374 } |
375 | 375 |
376 function errorHandler(error) | 376 function errorHandler(error) |
377 { | 377 { |
378 var errorMessage = WebInspector.IsolatedFileSystem.errorMessage(erro
r); | 378 var errorMessage = WebInspector.IsolatedFileSystem.errorMessage(erro
r); |
379 console.error(errorMessage + " when requesting entry '" + path + "'"
); | 379 console.error(errorMessage + " when requesting entry '" + path + "'"
); |
380 callback([]); | 380 callback([]); |
381 } | 381 } |
382 } | 382 } |
383 } | 383 } |
OLD | NEW |