swfile.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /************************************************************************
  2. * AUTHOR: NiuJiuRu
  3. * FILENAME: swfile.h
  4. * CONTENT: 常用的文件操作接口函数
  5. * NOTE:
  6. * HISTORY:
  7. * 1, [2010-08-19] created by NiuJiuRu
  8. * 2, [2014-01-10] 整体优化修改
  9. * 3, [2014-01-22] 整体优化修改
  10. ************************************************************************/
  11. #ifndef __SWFILE_H__
  12. #define __SWFILE_H__
  13. #ifdef __cplusplus
  14. extern "C"
  15. {
  16. #endif
  17. /* 装载文件 */
  18. int sw_file_load(const char *filename, const char *mode, char *buf, int bufSize);
  19. /* 更新文件 */
  20. int sw_file_update(const char *filename, const char *mode, const char *buf, int bufSize);
  21. /* 得到文件大小 */
  22. int sw_file_getSize(const char *filename);
  23. /* 重命名文件 */
  24. int sw_file_rename(const char *oldName, const char *newName);
  25. /* 拷贝文件 */
  26. int sw_file_copy(const char *existingFilename, const char *newFilename, bool failIfExists);
  27. /* 删除文件 */
  28. int sw_file_delete(const char *filename);
  29. /* 判断文件是否存在 */
  30. bool sw_file_exists(const char *filename);
  31. /* 读配置或字典文件(mode : "GetFieldName", 根据"字段值"获取"字段名"; "GetFieldValue", 根据"字段名"获取"字段值") */
  32. char *sw_file_getCfgString(const char *filename, const char *section, const char *mode, char *field, char *value, int resultBufSize);
  33. /* 写配置或字典文件(mode : "SetFieldName", 根据"字段值"设置"字段名"; "SetFieldValue", 根据"字段名"设置"字段值") */
  34. bool sw_file_setCfgString(const char *filename, const char *section, const char *mode, const char *field, const char *value, bool autoAdd);
  35. /* 从配置或字典文件中删除(mode : "DelFieldByName", 根据"字段名"删除该"字段"; "DelFieldByValue", 根据"字段值"删除该"字段") */
  36. bool sw_file_delCfgString(const char *filename, const char *section, const char *mode, const char *field, const char *value);
  37. #ifdef __cplusplus
  38. }
  39. #endif
  40. #endif /* __SWFILE_H__ */