OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /// @file file_io.cc | 5 /// @file file_io.cc |
6 /// This example demonstrates the use of persistent file I/O | 6 /// This example demonstrates the use of persistent file I/O |
7 | 7 |
8 #define __STDC_LIMIT_MACROS | 8 #define __STDC_LIMIT_MACROS |
9 #include <sstream> | 9 #include <sstream> |
10 #include <string> | 10 #include <string> |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 ShowStatusMessage("List success"); | 305 ShowStatusMessage("List success"); |
306 } | 306 } |
307 | 307 |
308 void MakeDir(int32_t /* result */, const std::string& dir_name) { | 308 void MakeDir(int32_t /* result */, const std::string& dir_name) { |
309 if (!file_system_ready_) { | 309 if (!file_system_ready_) { |
310 ShowErrorMessage("File system is not open", PP_ERROR_FAILED); | 310 ShowErrorMessage("File system is not open", PP_ERROR_FAILED); |
311 return; | 311 return; |
312 } | 312 } |
313 pp::FileRef ref(file_system_, dir_name.c_str()); | 313 pp::FileRef ref(file_system_, dir_name.c_str()); |
314 | 314 |
315 int32_t result = ref.MakeDirectory(pp::BlockUntilComplete()); | 315 int32_t result = ref.MakeDirectory( |
| 316 PP_MAKEDIRECTORYFLAG_NONE, pp::BlockUntilComplete()); |
316 if (result != PP_OK) { | 317 if (result != PP_OK) { |
317 ShowErrorMessage("Make directory failed", result); | 318 ShowErrorMessage("Make directory failed", result); |
318 return; | 319 return; |
319 } | 320 } |
320 ShowStatusMessage("Make directory success"); | 321 ShowStatusMessage("Make directory success"); |
321 } | 322 } |
322 | 323 |
323 /// Encapsulates our simple javascript communication protocol | 324 /// Encapsulates our simple javascript communication protocol |
324 void ShowErrorMessage(const std::string& message, int32_t result) { | 325 void ShowErrorMessage(const std::string& message, int32_t result) { |
325 std::stringstream ss; | 326 std::stringstream ss; |
(...skipping 26 matching lines...) Expand all Loading... |
352 }; | 353 }; |
353 | 354 |
354 namespace pp { | 355 namespace pp { |
355 /// Factory function called by the browser when the module is first loaded. | 356 /// Factory function called by the browser when the module is first loaded. |
356 /// The browser keeps a singleton of this module. It calls the | 357 /// The browser keeps a singleton of this module. It calls the |
357 /// CreateInstance() method on the object you return to make instances. There | 358 /// CreateInstance() method on the object you return to make instances. There |
358 /// is one instance per <embed> tag on the page. This is the main binding | 359 /// is one instance per <embed> tag on the page. This is the main binding |
359 /// point for your NaCl module with the browser. | 360 /// point for your NaCl module with the browser. |
360 Module* CreateModule() { return new FileIoModule(); } | 361 Module* CreateModule() { return new FileIoModule(); } |
361 } // namespace pp | 362 } // namespace pp |
OLD | NEW |