| 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 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 this._requestFileSystem(fileSystemLoaded.bind(this)); | 308 this._requestFileSystem(fileSystemLoaded.bind(this)); |
| 309 | 309 |
| 310 /** | 310 /** |
| 311 * @param {?DOMFileSystem} fs | 311 * @param {?DOMFileSystem} fs |
| 312 * @this {WebInspector.IsolatedFileSystem} | 312 * @this {WebInspector.IsolatedFileSystem} |
| 313 */ | 313 */ |
| 314 function fileSystemLoaded(fs) | 314 function fileSystemLoaded(fs) |
| 315 { | 315 { |
| 316 var domFileSystem = /** @type {!DOMFileSystem} */ (fs); | 316 var domFileSystem = /** @type {!DOMFileSystem} */ (fs); |
| 317 console.assert(domFileSystem); | 317 console.assert(domFileSystem); |
| 318 domFileSystem.root.getFile(path, null, fileEntryLoaded, errorHandler
.bind(this)); | 318 domFileSystem.root.getFile(path, null, fileEntryLoaded.bind(this), e
rrorHandler.bind(this)); |
| 319 } | 319 } |
| 320 | 320 |
| 321 /** | 321 /** |
| 322 * @param {!FileEntry} entry | 322 * @param {!FileEntry} entry |
| 323 * @this {WebInspector.IsolatedFileSystem} | 323 * @this {WebInspector.IsolatedFileSystem} |
| 324 */ | 324 */ |
| 325 function fileEntryLoaded(entry) | 325 function fileEntryLoaded(entry) |
| 326 { | 326 { |
| 327 entry.file(fileLoaded, errorHandler.bind(this)); | 327 entry.file(fileLoaded, errorHandler.bind(this)); |
| 328 } | 328 } |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 } | 361 } |
| 362 }, | 362 }, |
| 363 | 363 |
| 364 /** | 364 /** |
| 365 * @param {string} path | 365 * @param {string} path |
| 366 * @param {string} content | 366 * @param {string} content |
| 367 * @param {function()} callback | 367 * @param {function()} callback |
| 368 */ | 368 */ |
| 369 setFileContent: function(path, content, callback) | 369 setFileContent: function(path, content, callback) |
| 370 { | 370 { |
| 371 this._requestFileSystem(fileSystemLoaded); | 371 this._requestFileSystem(fileSystemLoaded.bind(this)); |
| 372 | 372 |
| 373 /** | 373 /** |
| 374 * @param {?DOMFileSystem} fs | 374 * @param {?DOMFileSystem} fs |
| 375 * @this {WebInspector.IsolatedFileSystem} | 375 * @this {WebInspector.IsolatedFileSystem} |
| 376 */ | 376 */ |
| 377 function fileSystemLoaded(fs) | 377 function fileSystemLoaded(fs) |
| 378 { | 378 { |
| 379 var domFileSystem = /** @type {!DOMFileSystem} */ (fs); | 379 var domFileSystem = /** @type {!DOMFileSystem} */ (fs); |
| 380 console.assert(domFileSystem); | 380 console.assert(domFileSystem); |
| 381 domFileSystem.root.getFile(path, { create: true }, fileEntryLoaded,
errorHandler.bind(this)); | 381 domFileSystem.root.getFile(path, { create: true }, fileEntryLoaded.b
ind(this), errorHandler.bind(this)); |
| 382 } | 382 } |
| 383 | 383 |
| 384 /** | 384 /** |
| 385 * @param {!FileEntry} entry | 385 * @param {!FileEntry} entry |
| 386 * @this {WebInspector.IsolatedFileSystem} | 386 * @this {WebInspector.IsolatedFileSystem} |
| 387 */ | 387 */ |
| 388 function fileEntryLoaded(entry) | 388 function fileEntryLoaded(entry) |
| 389 { | 389 { |
| 390 entry.createWriter(fileWriterCreated, errorHandler.bind(this)); | 390 entry.createWriter(fileWriterCreated.bind(this), errorHandler.bind(t
his)); |
| 391 } | 391 } |
| 392 | 392 |
| 393 /** | 393 /** |
| 394 * @param {!FileWriter} fileWriter | 394 * @param {!FileWriter} fileWriter |
| 395 * @this {WebInspector.IsolatedFileSystem} | 395 * @this {WebInspector.IsolatedFileSystem} |
| 396 */ | 396 */ |
| 397 function fileWriterCreated(fileWriter) | 397 function fileWriterCreated(fileWriter) |
| 398 { | 398 { |
| 399 fileWriter.onerror = errorHandler.bind(this); | 399 fileWriter.onerror = errorHandler.bind(this); |
| 400 fileWriter.onwriteend = fileTruncated; | 400 fileWriter.onwriteend = fileTruncated; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 renameFile: function(path, newName, callback) | 432 renameFile: function(path, newName, callback) |
| 433 { | 433 { |
| 434 newName = newName ? newName.trim() : newName; | 434 newName = newName ? newName.trim() : newName; |
| 435 if (!newName || newName.indexOf("/") !== -1) { | 435 if (!newName || newName.indexOf("/") !== -1) { |
| 436 callback(false); | 436 callback(false); |
| 437 return; | 437 return; |
| 438 } | 438 } |
| 439 var fileEntry; | 439 var fileEntry; |
| 440 var dirEntry; | 440 var dirEntry; |
| 441 var newFileEntry; | 441 var newFileEntry; |
| 442 this._requestFileSystem(fileSystemLoaded); | 442 this._requestFileSystem(fileSystemLoaded.bind(this)); |
| 443 | 443 |
| 444 /** | 444 /** |
| 445 * @param {?DOMFileSystem} fs | 445 * @param {?DOMFileSystem} fs |
| 446 * @this {WebInspector.IsolatedFileSystem} | 446 * @this {WebInspector.IsolatedFileSystem} |
| 447 */ | 447 */ |
| 448 function fileSystemLoaded(fs) | 448 function fileSystemLoaded(fs) |
| 449 { | 449 { |
| 450 var domFileSystem = /** @type {!DOMFileSystem} */ (fs); | 450 var domFileSystem = /** @type {!DOMFileSystem} */ (fs); |
| 451 console.assert(domFileSystem); | 451 console.assert(domFileSystem); |
| 452 domFileSystem.root.getFile(path, null, fileEntryLoaded, errorHandler
.bind(this)); | 452 domFileSystem.root.getFile(path, null, fileEntryLoaded.bind(this), e
rrorHandler.bind(this)); |
| 453 } | 453 } |
| 454 | 454 |
| 455 /** | 455 /** |
| 456 * @param {!FileEntry} entry | 456 * @param {!FileEntry} entry |
| 457 * @this {WebInspector.IsolatedFileSystem} | 457 * @this {WebInspector.IsolatedFileSystem} |
| 458 */ | 458 */ |
| 459 function fileEntryLoaded(entry) | 459 function fileEntryLoaded(entry) |
| 460 { | 460 { |
| 461 if (entry.name === newName) { | 461 if (entry.name === newName) { |
| 462 callback(false); | 462 callback(false); |
| 463 return; | 463 return; |
| 464 } | 464 } |
| 465 | 465 |
| 466 fileEntry = entry; | 466 fileEntry = entry; |
| 467 fileEntry.getParent(dirEntryLoaded, errorHandler.bind(this)); | 467 fileEntry.getParent(dirEntryLoaded.bind(this), errorHandler.bind(thi
s)); |
| 468 } | 468 } |
| 469 | 469 |
| 470 /** | 470 /** |
| 471 * @param {!Entry} entry | 471 * @param {!Entry} entry |
| 472 * @this {WebInspector.IsolatedFileSystem} |
| 472 */ | 473 */ |
| 473 function dirEntryLoaded(entry) | 474 function dirEntryLoaded(entry) |
| 474 { | 475 { |
| 475 dirEntry = entry; | 476 dirEntry = entry; |
| 476 dirEntry.getFile(newName, null, newFileEntryLoaded, newFileEntryLoad
ErrorHandler); | 477 dirEntry.getFile(newName, null, newFileEntryLoaded, newFileEntryLoad
ErrorHandler.bind(this)); |
| 477 } | 478 } |
| 478 | 479 |
| 479 /** | 480 /** |
| 480 * @param {!FileEntry} entry | 481 * @param {!FileEntry} entry |
| 481 */ | 482 */ |
| 482 function newFileEntryLoaded(entry) | 483 function newFileEntryLoaded(entry) |
| 483 { | 484 { |
| 484 callback(false); | 485 callback(false); |
| 485 } | 486 } |
| 486 | 487 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 568 } | 569 } |
| 569 | 570 |
| 570 function errorHandler(error) | 571 function errorHandler(error) |
| 571 { | 572 { |
| 572 var errorMessage = WebInspector.IsolatedFileSystem.errorMessage(erro
r); | 573 var errorMessage = WebInspector.IsolatedFileSystem.errorMessage(erro
r); |
| 573 console.error(errorMessage + " when requesting entry '" + path + "'"
); | 574 console.error(errorMessage + " when requesting entry '" + path + "'"
); |
| 574 callback([]); | 575 callback([]); |
| 575 } | 576 } |
| 576 } | 577 } |
| 577 } | 578 } |
| OLD | NEW |