Before

…lines 1–202 unchanged (202 lines)
203 *
204 * Unix flavors call fstat, while Windows variants use GetFileSize on a
205 * HANDLE queried from the libc FILE pointer.
206 */
207AWS_COMMON_API
208int aws_file_get_length(FILE *file, int64_t *length);
209
210AWS_EXTERN_C_END
211AWS_POP_SANE_WARNING_LEVEL
212
213#endif /* AWS_COMMON_FILE_H */
214

After

…lines 1–203 unchanged (203 lines)
204 * Unix flavors call fstat, while Windows variants use GetFileSize on a
205 * HANDLE queried from the libc FILE pointer.
206 */
207AWS_COMMON_API
208int aws_file_get_length(FILE *file, int64_t *length);
209
210/*
211 * Read from the file using the file path with DIRECT I/O, starting at offset to fill the output_buf or to the
212 * max_read_length.
213 * Using direct IO to bypass the OS cache. Helpful when the disk I/O outperform the kernel cache.
214 * If O_DIRECT is not supported, returns AWS_ERROR_UNSUPPORTED_OPERATION.
215 * Notes:
216 * - ONLY supports linux for now and raise AWS_ERROR_UNSUPPORTED_OPERATION on all other platforms (eg: FreeBSD).
217 * - check the NOTES for O_DIRECT in https://man7.org/linux/man-pages/man2/openat.2.html
218 * - The offset, length and output_buf->buffer all need to be aligned with the page size. Otherwise,
219 * AWS_ERROR_INVALID_ARGUMENT will be raised.
220 *
221 * @param file_path The file path to read from.
222 * @param offset The offset in the file to start reading from.
223 * @param max_read_length The maximum number of bytes to read.
224 * @param output_buf The buffer read to.
225 * @param out_actual_read The actual number of bytes read.
226 *
227 * Returns AWS_OP_SUCCESS, or AWS_OP_ERR (after an error has been raised).
228 */
229AWS_COMMON_API
230int aws_file_path_read_from_offset_direct_io(
231 const struct aws_string *file_path,
232 uint64_t offset,
233 size_t max_read_length,
234 struct aws_byte_buf *output_buf,
235 size_t *out_actual_read);
236
237/*
238 * Read from the file using the file path, starting at offset to fill the output_buf or to the
239 * max_read_length.
240 *
241 * @param file_path The file path to read from.
242 * @param offset The offset in the file to start reading from.
243 * @param max_read_length The maximum number of bytes to read.
244 * @param output_buf The buffer read to.
245 * @param out_actual_read The actual number of bytes read.
246 *
247 * Returns AWS_OP_SUCCESS, or AWS_OP_ERR (after an error has been raised).
248 */
249AWS_COMMON_API
250int aws_file_path_read_from_offset(
251 const struct aws_string *file_path,
252 uint64_t offset,
253 size_t max_read_length,
254 struct aws_byte_buf *output_buf,
255 size_t *out_actual_read);
256
257/*
258 * The function serve the same purpose as `aws_file_path_read_from_offset_direct_io`.
259 * Please use `aws_file_path_read_from_offset_direct_io` directly.
260 */
261AWS_COMMON_API
262int aws_file_path_read_from_offset_direct_io_with_chunk_size(
263 const struct aws_string *file_path,
264 uint64_t offset,
265 size_t max_read_length,
266 size_t max_chunk_size,
267 struct aws_byte_buf *output_buf,
268 size_t *out_actual_read);
269
270AWS_EXTERN_C_END AWS_POP_SANE_WARNING_LEVEL
271
272#endif /* AWS_COMMON_FILE_H */
273

Before

translation_unit
preproc_ifdef
#ifndef "#ifndef"
identifier "AWS_COMMON_FILE_H"
preproc_def
#define "#define"
identifier "AWS_COMMON_FILE_H"
comment "/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rig"...
preproc_include
#include "#include"
system_lib_string "<aws/common/byte_buf.h>"
preproc_include
#include "#include"
system_lib_string "<aws/common/common.h>"
preproc_include
#include "#include"
system_lib_string "<aws/common/platform.h>"
preproc_include
#include "#include"
system_lib_string "<stdio.h>"
type_identifier "AWS_PUSH_SANE_WARNING_LEVEL"
; ""
preproc_ifdef (+22 nodes collapsed)
struct_specifier
struct "struct"
type_identifier "aws_string"
; ";"
struct_specifier
struct "struct"
type_identifier "aws_directory_iterator"
; ";"
enum_specifier (+21 nodes collapsed)
; ";"
struct_specifier (+30 nodes collapsed)
; ";"
comment "/**\n * Invoked during calls to aws_directory_traverse() as a"...
type_definition (+27 nodes collapsed)
declaration
type_identifier "AWS_EXTERN_C_BEGIN"
comment "/**\n * Deprecated - Use aws_fopen_safe() instead, avoid cons"...
identifier "AWS_COMMON_API"
; ""
declaration (+25 nodes collapsed)
comment "/**\n * Opens file at file_path using mode. Returns the FILE "...
declaration (+31 nodes collapsed)
comment "/**\n * Creates a directory if it doesn't currently exist. If"...
declaration
type_identifier "AWS_COMMON_API"
ERROR
identifier "int"
function_declarator
identifier "aws_directory_create"
parameter_list
( "("
parameter_declaration
type_qualifier
const "const"
struct_specifier
struct "struct"
type_identifier "aws_string"
pointer_declarator
* "*"
identifier "dir_path"
) ")"
; ";"
comment "/**\n * Returns true if the directory currently exists. Other"...
declaration
type_identifier "AWS_COMMON_API"
ERROR
identifier "bool"
function_declarator
identifier "aws_directory_exists"
parameter_list
( "("
parameter_declaration
type_qualifier
const "const"
struct_specifier
struct "struct"
type_identifier "aws_string"
pointer_declarator
* "*"
identifier "dir_path"
) ")"
; ";"
comment "/**\n * Deletes a directory. If the directory is not empty, t"...
declaration (+23 nodes collapsed)
comment "/**\n * Deletes a file. Returns AWS_OP_SUCCESS if the operati"...
declaration
type_identifier "AWS_COMMON_API"
ERROR
identifier "int"
function_declarator
identifier "aws_file_delete"
parameter_list
( "("
parameter_declaration
type_qualifier
const "const"
struct_specifier
struct "struct"
type_identifier "aws_string"
pointer_declarator
* "*"
identifier "file_path"
) ")"
; ";"
comment "/**\n * Moves directory at from to to.\n * Returns AWS_OP_SUCC"...
declaration (+29 nodes collapsed)
comment "/**\n * Traverse a directory starting at path.\n *\n * If you w"...
declaration (+43 nodes collapsed)
comment "/**\n * Creates a read-only iterator of a directory starting "...
declaration
type_identifier "AWS_COMMON_API"
identifier "struct"
; ""
declaration (+27 nodes collapsed)
comment "/**\n * Moves the iterator to the next entry. Returns AWS_OP_"...
declaration
type_identifier "AWS_COMMON_API"
ERROR
identifier "int"
function_declarator
identifier "aws_directory_entry_iterator_next"
parameter_list
( "("
parameter_declaration
struct_specifier
struct "struct"
type_identifier "aws_directory_iterator"
pointer_declarator
* "*"
identifier "iterator"
) ")"
; ";"
comment "/**\n * Moves the iterator to the previous entry. Returns AWS"...
declaration
type_identifier "AWS_COMMON_API"
ERROR
identifier "int"
function_declarator
identifier "aws_directory_entry_iterator_previous"
parameter_list
( "("
parameter_declaration
struct_specifier
struct "struct"
type_identifier "aws_directory_iterator"
pointer_declarator
* "*"
identifier "iterator"
) ")"
; ";"
comment "/**\n * Cleanup and deallocate iterator\n */"
declaration
type_identifier "AWS_COMMON_API"
ERROR
identifier "void"
function_declarator
identifier "aws_directory_entry_iterator_destroy"
parameter_list
( "("
parameter_declaration
struct_specifier
struct "struct"
type_identifier "aws_directory_iterator"
pointer_declarator
* "*"
identifier "iterator"
) ")"
; ";"
comment "/**\n * Gets the aws_directory_entry value for iterator at th"...
declaration
type_identifier "AWS_COMMON_API"
type_qualifier
const "const"
identifier "struct"
; ""
declaration
type_identifier "aws_directory_entry"
pointer_declarator
* "*"
function_declarator
identifier "aws_directory_entry_iterator_get_value"
parameter_list
( "("
parameter_declaration
type_qualifier
const "const"
struct_specifier
struct "struct"
type_identifier "aws_directory_iterator"
pointer_declarator
* "*"
identifier "iterator"
) ")"
; ";"
comment "/**\n * Returns true iff the character is a directory separat"...
declaration
type_identifier "AWS_COMMON_API"
ERROR
identifier "bool"
function_declarator
identifier "aws_is_any_directory_separator"
parameter_list
( "("
parameter_declaration
primitive_type "char"
identifier "value"
) ")"
; ";"
comment "/**\n * Returns the directory separator used by the local pla"...
declaration
type_identifier "AWS_COMMON_API"
ERROR
identifier "char"
function_declarator
identifier "aws_get_platform_directory_separator"
parameter_list
( "("
parameter_declaration
primitive_type "void"
) ")"
; ";"
comment "/**\n * Normalizes the path by replacing any directory separa"...
declaration
type_identifier "AWS_COMMON_API"
ERROR
identifier "void"
function_declarator
identifier "aws_normalize_directory_separator"
parameter_list
( "("
parameter_declaration
struct_specifier
struct "struct"
type_identifier "aws_byte_buf"
pointer_declarator
* "*"
identifier "path"
) ")"
; ";"
comment "/**\n * Returns the current user's home directory.\n */"
declaration
type_identifier "AWS_COMMON_API"
identifier "struct"
; ""
declaration
type_identifier "aws_string"
pointer_declarator
* "*"
function_declarator
identifier "aws_get_home_directory"
parameter_list
( "("
parameter_declaration
struct_specifier
struct "struct"
type_identifier "aws_allocator"
pointer_declarator
* "*"
identifier "allocator"
) ")"
; ";"
comment "/**\n * Returns true if a file or path exists, otherwise, fal"...
declaration
type_identifier "AWS_COMMON_API"
ERROR
identifier "bool"
function_declarator
identifier "aws_path_exists"
parameter_list
( "("
parameter_declaration
type_qualifier
const "const"
struct_specifier
struct "struct"
type_identifier "aws_string"
pointer_declarator
* "*"
identifier "path"
) ")"
; ";"
comment "/*\n * Wrapper for highest-resolution platform-dependent seek"...
declaration (+23 nodes collapsed)
comment "/*\n * Wrapper for os-specific file length query. We can't u"...
declaration (+21 nodes collapsed)
declaration
type_identifier "AWS_EXTERN_C_END"
identifier "AWS_POP_SANE_WARNING_LEVEL"
; ""
#endif "#endif"
comment "/* AWS_COMMON_FILE_H */"

After

translation_unit
preproc_ifdef
#ifndef "#ifndef"
identifier "AWS_COMMON_FILE_H"
preproc_def
#define "#define"
identifier "AWS_COMMON_FILE_H"
comment "/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rig"...
preproc_include
#include "#include"
system_lib_string "<aws/common/byte_buf.h>"
preproc_include
#include "#include"
system_lib_string "<aws/common/common.h>"
preproc_include
#include "#include"
system_lib_string "<aws/common/platform.h>"
preproc_include
#include "#include"
system_lib_string "<stdio.h>"
type_identifier "AWS_PUSH_SANE_WARNING_LEVEL"
; ""
preproc_ifdef (+22 nodes collapsed)
struct_specifier
struct "struct"
type_identifier "aws_string"
; ";"
struct_specifier
struct "struct"
type_identifier "aws_directory_iterator"
; ";"
enum_specifier (+21 nodes collapsed)
; ";"
struct_specifier (+30 nodes collapsed)
; ";"
comment "/**\n * Invoked during calls to aws_directory_traverse() as a"...
type_definition (+27 nodes collapsed)
declaration
type_identifier "AWS_EXTERN_C_BEGIN"
comment "/**\n * Deprecated - Use aws_fopen_safe() instead, avoid cons"...
identifier "AWS_COMMON_API"
; ""
declaration (+25 nodes collapsed)
comment "/**\n * Opens file at file_path using mode. Returns the FILE "...
declaration (+31 nodes collapsed)
comment "/**\n * Creates a directory if it doesn't currently exist. If"...
declaration
type_identifier "AWS_COMMON_API"
ERROR
identifier "int"
function_declarator
identifier "aws_directory_create"
parameter_list
( "("
parameter_declaration
type_qualifier
const "const"
struct_specifier
struct "struct"
type_identifier "aws_string"
pointer_declarator
* "*"
identifier "dir_path"
) ")"
; ";"
comment "/**\n * Returns true if the directory currently exists. Other"...
declaration
type_identifier "AWS_COMMON_API"
ERROR
identifier "bool"
function_declarator
identifier "aws_directory_exists"
parameter_list
( "("
parameter_declaration
type_qualifier
const "const"
struct_specifier
struct "struct"
type_identifier "aws_string"
pointer_declarator
* "*"
identifier "dir_path"
) ")"
; ";"
comment "/**\n * Deletes a directory. If the directory is not empty, t"...
declaration (+23 nodes collapsed)
comment "/**\n * Deletes a file. Returns AWS_OP_SUCCESS if the operati"...
declaration
type_identifier "AWS_COMMON_API"
ERROR
identifier "int"
function_declarator
identifier "aws_file_delete"
parameter_list
( "("
parameter_declaration
type_qualifier
const "const"
struct_specifier
struct "struct"
type_identifier "aws_string"
pointer_declarator
* "*"
identifier "file_path"
) ")"
; ";"
comment "/**\n * Moves directory at from to to.\n * Returns AWS_OP_SUCC"...
declaration (+29 nodes collapsed)
comment "/**\n * Traverse a directory starting at path.\n *\n * If you w"...
declaration (+43 nodes collapsed)
comment "/**\n * Creates a read-only iterator of a directory starting "...
declaration
type_identifier "AWS_COMMON_API"
identifier "struct"
; ""
declaration (+27 nodes collapsed)
comment "/**\n * Moves the iterator to the next entry. Returns AWS_OP_"...
declaration
type_identifier "AWS_COMMON_API"
ERROR
identifier "int"
function_declarator
identifier "aws_directory_entry_iterator_next"
parameter_list
( "("
parameter_declaration
struct_specifier
struct "struct"
type_identifier "aws_directory_iterator"
pointer_declarator
* "*"
identifier "iterator"
) ")"
; ";"
comment "/**\n * Moves the iterator to the previous entry. Returns AWS"...
declaration
type_identifier "AWS_COMMON_API"
ERROR
identifier "int"
function_declarator
identifier "aws_directory_entry_iterator_previous"
parameter_list
( "("
parameter_declaration
struct_specifier
struct "struct"
type_identifier "aws_directory_iterator"
pointer_declarator
* "*"
identifier "iterator"
) ")"
; ";"
comment "/**\n * Cleanup and deallocate iterator\n */"
declaration
type_identifier "AWS_COMMON_API"
ERROR
identifier "void"
function_declarator
identifier "aws_directory_entry_iterator_destroy"
parameter_list
( "("
parameter_declaration
struct_specifier
struct "struct"
type_identifier "aws_directory_iterator"
pointer_declarator
* "*"
identifier "iterator"
) ")"
; ";"
comment "/**\n * Gets the aws_directory_entry value for iterator at th"...
declaration
type_identifier "AWS_COMMON_API"
type_qualifier
const "const"
identifier "struct"
; ""
declaration
type_identifier "aws_directory_entry"
pointer_declarator
* "*"
function_declarator
identifier "aws_directory_entry_iterator_get_value"
parameter_list
( "("
parameter_declaration
type_qualifier
const "const"
struct_specifier
struct "struct"
type_identifier "aws_directory_iterator"
pointer_declarator
* "*"
identifier "iterator"
) ")"
; ";"
comment "/**\n * Returns true iff the character is a directory separat"...
declaration
type_identifier "AWS_COMMON_API"
ERROR
identifier "bool"
function_declarator
identifier "aws_is_any_directory_separator"
parameter_list
( "("
parameter_declaration
primitive_type "char"
identifier "value"
) ")"
; ";"
comment "/**\n * Returns the directory separator used by the local pla"...
declaration
type_identifier "AWS_COMMON_API"
ERROR
identifier "char"
function_declarator
identifier "aws_get_platform_directory_separator"
parameter_list
( "("
parameter_declaration
primitive_type "void"
) ")"
; ";"
comment "/**\n * Normalizes the path by replacing any directory separa"...
declaration
type_identifier "AWS_COMMON_API"
ERROR
identifier "void"
function_declarator
identifier "aws_normalize_directory_separator"
parameter_list
( "("
parameter_declaration
struct_specifier
struct "struct"
type_identifier "aws_byte_buf"
pointer_declarator
* "*"
identifier "path"
) ")"
; ";"
comment "/**\n * Returns the current user's home directory.\n */"
declaration
type_identifier "AWS_COMMON_API"
identifier "struct"
; ""
declaration
type_identifier "aws_string"
pointer_declarator
* "*"
function_declarator
identifier "aws_get_home_directory"
parameter_list
( "("
parameter_declaration
struct_specifier
struct "struct"
type_identifier "aws_allocator"
pointer_declarator
* "*"
identifier "allocator"
) ")"
; ";"
comment "/**\n * Returns true if a file or path exists, otherwise, fal"...
declaration
type_identifier "AWS_COMMON_API"
ERROR
identifier "bool"
function_declarator
identifier "aws_path_exists"
parameter_list
( "("
parameter_declaration
type_qualifier
const "const"
struct_specifier
struct "struct"
type_identifier "aws_string"
pointer_declarator
* "*"
identifier "path"
) ")"
; ";"
comment "/*\n * Wrapper for highest-resolution platform-dependent seek"...
declaration (+23 nodes collapsed)
comment "/*\n * Wrapper for os-specific file length query. We can't u"...
declaration (+21 nodes collapsed)
comment "/*\n * Read from the file using the file path with DIRECT I/O"...
declaration
type_identifier "AWS_COMMON_API"
ERROR
identifier "int"
function_declarator
identifier "aws_file_path_read_from_offset_direct_io"
parameter_list
( "("
parameter_declaration
type_qualifier
const "const"
struct_specifier
struct "struct"
type_identifier "aws_string"
pointer_declarator
* "*"
identifier "file_path"
, ","
parameter_declaration
primitive_type "uint64_t"
identifier "offset"
, ","
parameter_declaration
primitive_type "size_t"
identifier "max_read_length"
, ","
parameter_declaration
struct_specifier
struct "struct"
type_identifier "aws_byte_buf"
pointer_declarator
* "*"
identifier "output_buf"
, ","
parameter_declaration
primitive_type "size_t"
pointer_declarator
* "*"
identifier "out_actual_read"
) ")"
; ";"
comment "/*\n * Read from the file using the file path, starting at of"...
declaration
type_identifier "AWS_COMMON_API"
ERROR
identifier "int"
function_declarator
identifier "aws_file_path_read_from_offset"
parameter_list
( "("
parameter_declaration
type_qualifier
const "const"
struct_specifier
struct "struct"
type_identifier "aws_string"
pointer_declarator
* "*"
identifier "file_path"
, ","
parameter_declaration
primitive_type "uint64_t"
identifier "offset"
, ","
parameter_declaration
primitive_type "size_t"
identifier "max_read_length"
, ","
parameter_declaration
struct_specifier
struct "struct"
type_identifier "aws_byte_buf"
pointer_declarator
* "*"
identifier "output_buf"
, ","
parameter_declaration
primitive_type "size_t"
pointer_declarator
* "*"
identifier "out_actual_read"
) ")"
; ";"
comment "/*\n * The function serve the same purpose as `aws_file_path_"...
declaration
type_identifier "AWS_COMMON_API"
ERROR
identifier "int"
function_declarator
identifier "aws_file_path_read_from_offset_direct_io_with_chunk_size"
parameter_list
( "("
parameter_declaration
type_qualifier
const "const"
struct_specifier
struct "struct"
type_identifier "aws_string"
pointer_declarator
* "*"
identifier "file_path"
, ","
parameter_declaration
primitive_type "uint64_t"
identifier "offset"
, ","
parameter_declaration
primitive_type "size_t"
identifier "max_read_length"
, ","
parameter_declaration
primitive_type "size_t"
identifier "max_chunk_size"
, ","
parameter_declaration
struct_specifier
struct "struct"
type_identifier "aws_byte_buf"
pointer_declarator
* "*"
identifier "output_buf"
, ","
parameter_declaration
primitive_type "size_t"
pointer_declarator
* "*"
identifier "out_actual_read"
) ")"
; ";"
declaration
type_identifier "AWS_EXTERN_C_END"
identifier "AWS_POP_SANE_WARNING_LEVEL"
; ""
#endif "#endif"
comment "/* AWS_COMMON_FILE_H */"