• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2011 The Android Open Source Project
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 /**
17  ************************************************************************
18  * @file         M4OSA_FileCommon.h
19  * @ingroup      OSAL
20  * @brief        File common
21  * @note         This file declares functions and types used by both the file
22  *               writer and file reader.
23  ************************************************************************
24 */
25 
26 
27 #ifndef M4OSA_FILECOMMON_H
28 #define M4OSA_FILECOMMON_H
29 
30 #include "M4OSA_Types.h"
31 #include "M4OSA_Time.h"
32 #include "M4OSA_Error.h"
33 #include "M4OSA_OptionID.h"
34 
35 
36 typedef M4OSA_Int32 M4OSA_FilePosition;
37 
38 /** This enum defines the application mode access.
39  *  ie, the application uses a file descriptor to read or to write  or
40  *  both to read and write at the same time.
41  *  This structure is used for MM project only. It enables to read and write to a file
42  *  with one descriptor.
43  */
44 typedef enum
45 {
46    M4OSA_kDescNoneAccess    = 0x00,
47    M4OSA_kDescReadAccess    = 0x01,    /** The Descriptor reads only from the file */
48    M4OSA_kDescWriteAccess    = 0x02,    /** The Descriptor writes only from the file*/
49    M4OSA_kDescRWAccess        = 0x03    /** The Descriptor reads and writes from/in the file*/
50 } M4OSA_DescrModeAccess;
51 
52 
53 /** This enum defines the file mode access. Both text mode as binary mode
54     cannot be set together.*/
55 typedef enum
56 {
57    /** The file must be accessed in read only mode*/
58    M4OSA_kFileRead             = 0x01,
59    /** The file must be accessed in write only mode*/
60    M4OSA_kFileWrite            = 0x02,
61    /** The file must be accessed in append mode (An existing file must
62        be available to append data)*/
63    M4OSA_kFileAppend           = 0x04,
64    /** If the file does not exist, it will be created*/
65    M4OSA_kFileCreate           = 0x08,
66    /** Data are processed as binary one, there is no data management*/
67    M4OSA_kFileIsTextMode       = 0x10
68 } M4OSA_FileModeAccess;
69 
70 
71 /** This type is used to store a date.*/
72 typedef struct
73 {
74    /** Time scale (tick number per second)*/
75    M4OSA_UInt32 timeScale;
76    /** Date expressed in the time scale*/
77    M4OSA_Time   time;
78    /** Year of the absolute time (1900, 1970 or 2000)*/
79    M4OSA_UInt32 referenceYear;
80 } M4OSA_Date;
81 
82 
83 /** This strucure defines the file attributes*/
84 typedef struct
85 {
86    /** The file mode access*/
87    M4OSA_FileModeAccess    modeAccess;
88    /** The creation date*/
89    M4OSA_Date              creationDate;
90    /** The last modification date*/
91    M4OSA_Date              modifiedDate;
92    /** The last access date (read)*/
93    M4OSA_Date              lastAccessDate;
94 } M4OSA_FileAttribute;
95 
96 
97 
98 /** This enum defines the seek behavior*/
99 typedef enum M4OSA_FileSeekAccessMode
100 {
101    /** Relative to the beginning of the file*/
102    M4OSA_kFileSeekBeginning            = 0x01,
103    /** Relative to the end of the file*/
104    M4OSA_kFileSeekEnd                  = 0x02,
105    /** Relative to the current file position*/
106    M4OSA_kFileSeekCurrent              = 0x03
107 } M4OSA_FileSeekAccessMode;
108 
109 
110 /* Error codes */
111 #define M4ERR_FILE_NOT_FOUND         M4OSA_ERR_CREATE(M4_ERR, M4OSA_FILE_COMMON, 0x000001)
112 #define M4ERR_FILE_LOCKED            M4OSA_ERR_CREATE(M4_ERR, M4OSA_FILE_COMMON, 0x000002)
113 #define M4ERR_FILE_BAD_MODE_ACCESS   M4OSA_ERR_CREATE(M4_ERR, M4OSA_FILE_COMMON, 0x000003)
114 #define M4ERR_FILE_INVALID_POSITION  M4OSA_ERR_CREATE(M4_ERR, M4OSA_FILE_COMMON, 0x000004)
115 
116 
117 #endif /*M4OSA_FILECOMMON_H*/
118 
119