summaryrefslogtreecommitdiffstats
path: root/libvideoeditor/osal/inc/M4OSA_FileCommon.h
blob: f2afb8c6a79317958d898d6166010e80930683ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/*
 * Copyright (C) 2011 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/**
 ************************************************************************
 * @file         M4OSA_FileCommon.h
 * @ingroup      OSAL
 * @brief        File common
 * @note         This file declares functions and types used by both the file
 *               writer and file reader.
 ************************************************************************
*/


#ifndef M4OSA_FILECOMMON_H
#define M4OSA_FILECOMMON_H

#include "M4OSA_Types.h"
#include "M4OSA_Time.h"
#include "M4OSA_Error.h"
#include "M4OSA_OptionID.h"


typedef M4OSA_Int32 M4OSA_FilePosition;

/** This enum defines the application mode access.
 *  ie, the application uses a file descriptor to read or to write  or
 *  both to read and write at the same time.
 *  This structure is used for MM project only. It enables to read and write to a file
 *  with one descriptor.
 */
typedef enum
{
   M4OSA_kDescNoneAccess    = 0x00,
   M4OSA_kDescReadAccess    = 0x01,    /** The Descriptor reads only from the file */
   M4OSA_kDescWriteAccess    = 0x02,    /** The Descriptor writes only from the file*/
   M4OSA_kDescRWAccess        = 0x03    /** The Descriptor reads and writes from/in the file*/
} M4OSA_DescrModeAccess;


/** This enum defines the file mode access. Both text mode as binary mode
    cannot be set together.*/
typedef enum
{
   /** The file must be accessed in read only mode*/
   M4OSA_kFileRead             = 0x01,
   /** The file must be accessed in write only mode*/
   M4OSA_kFileWrite            = 0x02,
   /** The file must be accessed in append mode (An existing file must
       be available to append data)*/
   M4OSA_kFileAppend           = 0x04,
   /** If the file does not exist, it will be created*/
   M4OSA_kFileCreate           = 0x08,
   /** Data are processed as binary one, there is no data management*/
   M4OSA_kFileIsTextMode       = 0x10
} M4OSA_FileModeAccess;


/** This type is used to store a date.*/
typedef struct
{
   /** Time scale (tick number per second)*/
   M4OSA_UInt32 timeScale;
   /** Date expressed in the time scale*/
   M4OSA_Time   time;
   /** Year of the absolute time (1900, 1970 or 2000)*/
   M4OSA_UInt32 referenceYear;
} M4OSA_Date;


/** This strucure defines the file attributes*/
typedef struct
{
   /** The file mode access*/
   M4OSA_FileModeAccess    modeAccess;
   /** The creation date*/
   M4OSA_Date              creationDate;
   /** The last modification date*/
   M4OSA_Date              modifiedDate;
   /** The last access date (read)*/
   M4OSA_Date              lastAccessDate;
} M4OSA_FileAttribute;



/** This enum defines the seek behavior*/
typedef enum M4OSA_FileSeekAccessMode
{
   /** Relative to the beginning of the file*/
   M4OSA_kFileSeekBeginning            = 0x01,
   /** Relative to the end of the file*/
   M4OSA_kFileSeekEnd                  = 0x02,
   /** Relative to the current file position*/
   M4OSA_kFileSeekCurrent              = 0x03
} M4OSA_FileSeekAccessMode;


/* Error codes */
#define M4ERR_FILE_NOT_FOUND         M4OSA_ERR_CREATE(M4_ERR, M4OSA_FILE_COMMON, 0x000001)
#define M4ERR_FILE_LOCKED            M4OSA_ERR_CREATE(M4_ERR, M4OSA_FILE_COMMON, 0x000002)
#define M4ERR_FILE_BAD_MODE_ACCESS   M4OSA_ERR_CREATE(M4_ERR, M4OSA_FILE_COMMON, 0x000003)
#define M4ERR_FILE_INVALID_POSITION  M4OSA_ERR_CREATE(M4_ERR, M4OSA_FILE_COMMON, 0x000004)


#endif /*M4OSA_FILECOMMON_H*/