FileBase.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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_FILEBASE_H
  17. #define MBED_FILEBASE_H
  18. typedef int FILEHANDLE;
  19. #include <cstdio>
  20. #include <cstring>
  21. #include "platform/platform.h"
  22. #include "platform/SingletonPtr.h"
  23. #include "platform/PlatformMutex.h"
  24. #include "platform/NonCopyable.h"
  25. namespace mbed {
  26. typedef enum {
  27. FilePathType,
  28. FileSystemPathType
  29. } PathType;
  30. /** \addtogroup platform */
  31. /** @{*/
  32. /**
  33. * \defgroup platform_FileBase FileBase class
  34. * @{
  35. */
  36. /** Class FileBase
  37. *
  38. */
  39. class FileBase : private NonCopyable<FileBase> {
  40. public:
  41. FileBase(const char *name, PathType t);
  42. virtual ~FileBase();
  43. const char *getName(void);
  44. PathType getPathType(void);
  45. static FileBase *lookup(const char *name, unsigned int len);
  46. static FileBase *get(int n);
  47. /* disallow copy constructor and assignment operators */
  48. private:
  49. static FileBase *_head;
  50. static SingletonPtr<PlatformMutex> _mutex;
  51. FileBase *_next;
  52. const char *const _name;
  53. const PathType _path_type;
  54. };
  55. /**@}*/
  56. /**@}*/
  57. } // namespace mbed
  58. #endif