OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2014 The Native Client Authors. All rights reserved. | 2 * Copyright (c) 2014 The Native Client Authors. All rights reserved. |
3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
5 */ | 5 */ |
6 | 6 |
| 7 /* globals NaClProcessManager, makeRootDir */ |
| 8 |
7 'use strict'; | 9 'use strict'; |
8 | 10 |
9 function newWindow() { | 11 function newWindow() { |
10 chrome.app.window.create('bash.html', { | 12 chrome.app.window.create('bash.html', { |
11 'bounds': { | 13 'bounds': { |
12 'width': 800, | 14 'width': 800, |
13 'height': 600, | 15 'height': 600, |
14 }, | 16 }, |
15 }); | 17 }); |
16 } | 18 } |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 break; | 89 break; |
88 case 'nacl_sigint': | 90 case 'nacl_sigint': |
89 manager.sigint(); | 91 manager.sigint(); |
90 break; | 92 break; |
91 case 'set_local_repo': | 93 case 'set_local_repo': |
92 /* | 94 /* |
93 * Modify /usr/etc/pkg/repos/Local.conf, updating the URL and | 95 * Modify /usr/etc/pkg/repos/Local.conf, updating the URL and |
94 * enabling the repo. | 96 * enabling the repo. |
95 * Also, disable /usr/etc/pkg/repos/NaCl.conf. | 97 * Also, disable /usr/etc/pkg/repos/NaCl.conf. |
96 */ | 98 */ |
97 console.log('set_local_repo') | 99 console.log('set_local_repo'); |
98 var local_repo_file = '/usr/etc/pkg/repos/Local.conf'; | 100 var local_repo_file = '/usr/etc/pkg/repos/Local.conf'; |
99 files.readText(local_repo_file).then(function(data) { | 101 files.readText(local_repo_file).then(function(data) { |
100 data = data.replace('http://localhost:5103', msg.data); | 102 data = data.replace('http://localhost:5103', msg.data); |
101 data = data.replace('ENABLED: NO', 'ENABLED: YES', data); | 103 data = data.replace('ENABLED: NO', 'ENABLED: YES', data); |
102 return files.writeText(local_repo_file, data); | 104 return files.writeText(local_repo_file, data); |
103 }).then(function() { | 105 }).then(function() { |
104 var repo_file = '/usr/etc/pkg/repos/NaCl.conf'; | 106 var repo_file = '/usr/etc/pkg/repos/NaCl.conf'; |
105 files.readText(repo_file).then(function(data) { | 107 files.readText(repo_file).then(function(data) { |
106 data = data.replace('ENABLED: YES', 'ENABLED: NO', data); | 108 data = data.replace('ENABLED: YES', 'ENABLED: NO', data); |
107 return files.writeText(repo_file, data); | 109 return files.writeText(repo_file, data); |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 reject(new Error(FileManager.FS_NOT_INITIALIZED)); | 262 reject(new Error(FileManager.FS_NOT_INITIALIZED)); |
261 return; | 263 return; |
262 } | 264 } |
263 | 265 |
264 var pathInfo = self.translatePath(fileName); | 266 var pathInfo = self.translatePath(fileName); |
265 pathInfo.fs.root.getFile(pathInfo.path, {create: true}, function(fe) { | 267 pathInfo.fs.root.getFile(pathInfo.path, {create: true}, function(fe) { |
266 fe.createWriter(onCreateWriter, reject); | 268 fe.createWriter(onCreateWriter, reject); |
267 }, reject); | 269 }, reject); |
268 | 270 |
269 function onCreateWriter(writer) { | 271 function onCreateWriter(writer) { |
270 var blob = new Blob([content], {type:'text/plain'}) | 272 var blob = new Blob([content], {type:'text/plain'}); |
271 // Discard arguments. | 273 // Discard arguments. |
272 writer.onwriteend = function() { | 274 writer.onwriteend = function() { |
273 // truncate done, write data | 275 // truncate done, write data |
274 if (writer.length === 0) | 276 if (writer.length === 0) |
275 writer.write(blob); | 277 writer.write(blob); |
276 else | 278 else |
277 resolve(); | 279 resolve(); |
278 } | 280 }; |
279 writer.onerror = reject; | 281 writer.onerror = reject; |
280 writer.truncate(0); | 282 writer.truncate(0); |
281 } | 283 } |
282 }); | 284 }); |
283 }; | 285 }; |
284 | 286 |
285 /** | 287 /** |
286 * Remove a file from the filesystem. This does not work on directories. | 288 * Remove a file from the filesystem. This does not work on directories. |
287 * @param {string} fileName The name of the file. | 289 * @param {string} fileName The name of the file. |
288 */ | 290 */ |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 } | 335 } |
334 | 336 |
335 var pathInfo = self.translatePath(fileName); | 337 var pathInfo = self.translatePath(fileName); |
336 pathInfo.fs.root.getDirectory(pathInfo.path, {}, function(dir) { | 338 pathInfo.fs.root.getDirectory(pathInfo.path, {}, function(dir) { |
337 dir.removeRecursively(function() { | 339 dir.removeRecursively(function() { |
338 resolve(); | 340 resolve(); |
339 }, reject); | 341 }, reject); |
340 }, reject); | 342 }, reject); |
341 }); | 343 }); |
342 }; | 344 }; |
OLD | NEW |