summaryrefslogtreecommitdiff
path: root/src/lib/elementary/elm_code_file.h
blob: 9bafe431ac8ac2911f76f1594e2aa88b4223a2a9 (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
#ifndef ELM_CODE_FILE_H_
# define ELM_CODE_FILE_H_

#ifdef __cplusplus
extern "C" {
#endif

/**
 * @file
 * @brief These routines are used for interacting with files using Elm Code.
 */

typedef enum {
   ELM_CODE_FILE_LINE_ENDING_UNIX = 0,
   ELM_CODE_FILE_LINE_ENDING_WINDOWS
} Elm_Code_File_Line_Ending;

struct _Elm_Code_File
{
   void *parent;

   Eina_List *lines;
   Eina_File *file;
   void *map;
   const char *mime;

   Elm_Code_File_Line_Ending line_ending;
};

/**
 * @brief File handling functions.
 * @defgroup File  I/O at a file level
 *
 * @{
 *
 * Functions for file handling within elm code.
 *
 */

EAPI Elm_Code_File *elm_code_file_new(Elm_Code *code);

EAPI Elm_Code_File *elm_code_file_open(Elm_Code *code, const char *path);

EAPI void elm_code_file_save(Elm_Code_File *file);

EAPI void elm_code_file_free(Elm_Code_File *file);

EAPI void elm_code_file_close(Elm_Code_File *file);

/**
 * Get the filename for the file specified.
 *
 * @return the filename or NULL if it is an in-memory file
 */
EAPI const char *elm_code_file_filename_get(Elm_Code_File *file);

/**
 * Get the file path for the file specified.
 *
 * @return the file's path or NULL if it is an in-memory file
 */
EAPI const char *elm_code_file_path_get(Elm_Code_File *file);

EAPI Elm_Code_File_Line_Ending elm_code_file_line_ending_get(Elm_Code_File *file);

EAPI const char *elm_code_file_line_ending_chars_get(Elm_Code_File *file, short *length);

/**
 * @}
 *
 * @brief Content functions.
 * @defgroup Content  Functions for accessing file content
 *
 * @{
 *
 * File content handling functions.
 *
 */

EAPI void elm_code_file_clear(Elm_Code_File *file);

EAPI unsigned int elm_code_file_lines_get(Elm_Code_File *file);

EAPI void elm_code_file_line_append(Elm_Code_File *file, const char *line, int length, void *data);

EAPI void elm_code_file_line_insert(Elm_Code_File *file, unsigned int row, const char *line, int length, void *data);

EAPI void elm_code_file_line_remove(Elm_Code_File *file, unsigned int row);

EAPI Elm_Code_Line *elm_code_file_line_get(Elm_Code_File *file, unsigned int line);

/**
 * @}
 */

#ifdef __cplusplus
}
#endif

#endif /* ELM_CODE_FILE_H_ */