Naze32 clone with Frysky receiver
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

LocalFileSystem.h 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /* mbed Microcontroller Library
  2. * Copyright (c) 2006-2013 ARM Limited
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #ifndef MBED_LOCALFILESYSTEM_H
  17. #define MBED_LOCALFILESYSTEM_H
  18. #include "platform.h"
  19. #if DEVICE_LOCALFILESYSTEM
  20. #include "FileSystemLike.h"
  21. namespace mbed {
  22. FILEHANDLE local_file_open(const char* name, int flags);
  23. class LocalFileHandle : public FileHandle {
  24. public:
  25. LocalFileHandle(FILEHANDLE fh);
  26. virtual int close();
  27. virtual ssize_t write(const void *buffer, size_t length);
  28. virtual ssize_t read(void *buffer, size_t length);
  29. virtual int isatty();
  30. virtual off_t lseek(off_t position, int whence);
  31. virtual int fsync();
  32. virtual off_t flen();
  33. protected:
  34. FILEHANDLE _fh;
  35. int pos;
  36. };
  37. /** A filesystem for accessing the local mbed Microcontroller USB disk drive
  38. *
  39. * This allows programs to read and write files on the same disk drive that is used to program the
  40. * mbed Microcontroller. Once created, the standard C file access functions are used to open,
  41. * read and write files.
  42. *
  43. * Example:
  44. * @code
  45. * #include "mbed.h"
  46. *
  47. * LocalFileSystem local("local"); // Create the local filesystem under the name "local"
  48. *
  49. * int main() {
  50. * FILE *fp = fopen("/local/out.txt", "w"); // Open "out.txt" on the local file system for writing
  51. * fprintf(fp, "Hello World!");
  52. * fclose(fp);
  53. * remove("/local/out.txt"); // Removes the file "out.txt" from the local file system
  54. *
  55. * DIR *d = opendir("/local"); // Opens the root directory of the local file system
  56. * struct dirent *p;
  57. * while((p = readdir(d)) != NULL) { // Print the names of the files in the local file system
  58. * printf("%s\n", p->d_name); // to stdout.
  59. * }
  60. * closedir(d);
  61. * }
  62. * @endcode
  63. *
  64. * @note
  65. * If the microcontroller program makes an access to the local drive, it will be marked as "removed"
  66. * on the Host computer. This means it is no longer accessible from the Host Computer.
  67. *
  68. * The drive will only re-appear when the microcontroller program exists. Note that if the program does
  69. * not exit, you will need to hold down reset on the mbed Microcontroller to be able to see the drive again!
  70. */
  71. class LocalFileSystem : public FileSystemLike {
  72. public:
  73. LocalFileSystem(const char* n) : FileSystemLike(n) {
  74. }
  75. virtual FileHandle *open(const char* name, int flags);
  76. virtual int remove(const char *filename);
  77. virtual DirHandle *opendir(const char *name);
  78. };
  79. } // namespace mbed
  80. #endif
  81. #endif