4 * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
23 * @desc Helper functions for working with files
26 #ifndef _RESOURCED_FILE_HELPER_H_
27 #define _RESOURCED_FILE_HELPER_H_
29 #include "resourced.h"
33 #endif /* __cplusplus */
36 * @desc write string to the file
37 * @param path - path to the file, str - string is written to the file
38 * @return negative value if error
40 int fwrite_str(const char *path, const char *str);
42 int fwrite_int(const char *path, const int number);
44 int fwrite_uint(const char *path, const u_int32_t number);
46 int fwrite_ulong(const char *path, const unsigned long number);
47 int fwrite_ulonglong(const char *path, const unsigned long long number);
49 int fread_str(const char *path, char **str);
51 int fread_nth_int(const char *path, size_t n, int32_t *number);
53 inline int fread_int(const char *path, int32_t *number)
55 return fread_nth_int(path, 0, number);
58 int fread_nth_uint(const char *path, size_t n, u_int32_t *number);
60 inline int fread_uint(const char *path, u_int32_t *number)
62 return fread_nth_uint(path, 0, number);
65 int fread_nth_ulong(const char *path, size_t n, unsigned long *number);
66 int fread_nth_ulonglong(const char *path, size_t n, unsigned long long *number);
68 inline int fread_ulong(const char *path, unsigned long *number)
70 return fread_nth_ulong(path, 0, number);
73 inline int fread_ulonglong(const char *path, unsigned long long *number)
75 return fread_nth_ulonglong(path, 0, number);
80 #endif /* __cplusplus */
82 #endif /*_RESOURCED_FILE_HELPER_H_*/