1 #ifndef ELM_CODE_FILE_H_ 2 # define ELM_CODE_FILE_H_ 3 4 #ifdef __cplusplus 5 extern "C" { 6 #endif 7 8 /** 9 * @file 10 * @brief These routines are used for interacting with files using Elm Code. 11 */ 12 13 typedef enum { 14 ELM_CODE_FILE_LINE_ENDING_UNIX = 0, 15 ELM_CODE_FILE_LINE_ENDING_WINDOWS 16 } Elm_Code_File_Line_Ending; 17 18 struct _Elm_Code_File 19 { 20 void *parent; 21 22 Eina_List *lines; 23 Eina_File *file; 24 void *map; 25 const char *mime; 26 27 Elm_Code_File_Line_Ending line_ending; 28 }; 29 30 /** 31 * @brief File handling functions. 32 * @defgroup File I/O at a file level 33 * 34 * @{ 35 * 36 * Functions for file handling within elm code. 37 * 38 */ 39 40 EAPI Elm_Code_File *elm_code_file_new(Elm_Code *code); 41 42 EAPI Elm_Code_File *elm_code_file_open(Elm_Code *code, const char *path); 43 44 EAPI void elm_code_file_save(Elm_Code_File *file); 45 46 EAPI void elm_code_file_free(Elm_Code_File *file); 47 48 EAPI void elm_code_file_close(Elm_Code_File *file); 49 50 /** 51 * Get the filename for the file specified. 52 * 53 * @return the filename or NULL if it is an in-memory file 54 */ 55 EAPI const char *elm_code_file_filename_get(Elm_Code_File *file); 56 57 /** 58 * Get the file path for the file specified. 59 * 60 * @return the file's path or NULL if it is an in-memory file 61 */ 62 EAPI const char *elm_code_file_path_get(Elm_Code_File *file); 63 64 EAPI Elm_Code_File_Line_Ending elm_code_file_line_ending_get(Elm_Code_File *file); 65 66 EAPI const char *elm_code_file_line_ending_chars_get(Elm_Code_File *file, short *length); 67 68 /** 69 * @} 70 * 71 * @brief Content functions. 72 * @defgroup Content Functions for accessing file content 73 * 74 * @{ 75 * 76 * File content handling functions. 77 * 78 */ 79 80 EAPI void elm_code_file_clear(Elm_Code_File *file); 81 82 EAPI unsigned int elm_code_file_lines_get(Elm_Code_File *file); 83 84 EAPI void elm_code_file_line_append(Elm_Code_File *file, const char *line, int length, void *data); 85 86 EAPI void elm_code_file_line_insert(Elm_Code_File *file, unsigned int row, const char *line, int length, void *data); 87 88 EAPI void elm_code_file_line_remove(Elm_Code_File *file, unsigned int row); 89 90 EAPI Elm_Code_Line *elm_code_file_line_get(Elm_Code_File *file, unsigned int line); 91 92 /** 93 * @} 94 */ 95 96 #ifdef __cplusplus 97 } 98 #endif 99 100 #endif /* ELM_CODE_FILE_H_ */ 101