smb_stat.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. //---------------------------------------------------------------------------
  2. // __________________ _________ _____ _____ .__ ._.
  3. // \______ \______ \ / _____/ / \ / _ \ |__| ____ | |
  4. // | | _/| | \ \_____ \ / \ / \ / /_\ \| _/ __ \ | |
  5. // | | \| ` \/ / Y \ / | | \ ___/ \|
  6. // |______ /_______ /_______ \____|__ / /\ \____|__ |__|\___ | __
  7. // \/ \/ \/ \/ )/ \/ \/ \/
  8. //
  9. // This file is part of libdsm. Copyright © 2014 VideoLabs SAS
  10. //
  11. // Author: Julien 'Lta' BALLET <contact@lta.io>
  12. //
  13. // This program is free software. It comes without any warranty, to the extent
  14. // permitted by applicable law. You can redistribute it and/or modify it under
  15. // the terms of the Do What The Fuck You Want To Public License, Version 2, as
  16. // published by Sam Hocevar. See the COPYING file for more details.
  17. //----------------------------------------------------------------------------
  18. /**
  19. * @file smb_stat.h
  20. * @brief File status / listing
  21. */
  22. #ifndef __BDSM_SMB_TRANS2_H_
  23. #define __BDSM_SMB_TRANS2_H_
  24. #include "bdsm/smb_defs.h"
  25. #include "bdsm/smb_session.h"
  26. /// smb_stat_get() OP: Get file size
  27. #define SMB_STAT_SIZE 0
  28. /// smb_stat_get() OP: Get file allocation size (Size on disk)
  29. #define SMB_STAT_ALLOC_SIZE 1
  30. /// smb_stat_get() OP: 0 -> not a directory, != 0 -> directory
  31. #define SMB_STAT_ISDIR 2
  32. /// smb_stat_get() OP: Get file creation time
  33. #define SMB_STAT_CTIME 3
  34. /// smb_stat_get() OP: Get file last access time
  35. #define SMB_STAT_ATIME 4
  36. /// smb_stat_get() OP: Get file last write time
  37. #define SMB_STAT_WTIME 5
  38. /// smb_stat_get() OP: Get file last moditification time
  39. #define SMB_STAT_MTIME 6
  40. /**
  41. * @brief Returns infos about files matching a pattern
  42. * @details This functions uses the FIND_FIRST2 SMB operations to list files
  43. * matching a certain pattern. It's basically used to list folder contents
  44. *
  45. * @param s The session object
  46. * @param tid The share inside of which we want to find files obtained by
  47. * smb_tree_connect()
  48. * @param pattern The pattern to match files. '\\*' will list all the files at
  49. * the root of the share. '\\afolder\\*' will list all the files inside of the
  50. * 'afolder' directory.
  51. * @return An opaque list of smb_stat or NULL in case of error
  52. */
  53. smb_stat_list smb_find(smb_session *s, smb_tid tid, const char *pattern);
  54. /**
  55. * @brief Get the status of a file from it's path inside of a share
  56. *
  57. * @param s The session object
  58. * @param tid The tree id of a share obtained by smb_tree_connect()
  59. * @param path The full path of the file relative to the root of the share
  60. * (e.g. '\\folder\\file.ext')
  61. * @return An opaque smb_stat or NULL in case of error
  62. */
  63. smb_stat smb_fstat(smb_session *s, smb_tid tid, const char *path);
  64. /**
  65. * @brief Get the status of an open file from it's file descriptor
  66. * @details The file status will be those at the time of open
  67. *
  68. * @param s The session object
  69. * @param fd The smb_fd from which you want infos/status
  70. *
  71. * @return An opaque smb_stat or NULL in case of error
  72. */
  73. smb_stat smb_stat_fd(smb_session *s, smb_fd fd);
  74. /**
  75. * @brief Get the number of item in a smb_stat_list file info
  76. *
  77. * @param list The list you want the length of
  78. * @return The length of the list. It returns 0 if the list is invalid
  79. */
  80. size_t smb_stat_list_count(smb_stat_list list);
  81. /**
  82. * @brief Get the element at the given position.
  83. *
  84. * @param list A stat list
  85. * @param index The position of the element you want.
  86. *
  87. * @return An opaque smb_stat or NULL in case of error
  88. */
  89. smb_stat smb_stat_list_at(smb_stat_list list, size_t index);
  90. /**
  91. * @brief Get the name of the file from its status
  92. *
  93. * @param info A file status
  94. * @return A null-terminated string in you current locale encoding or NULL.
  95. */
  96. const char *smb_stat_name(smb_stat info);
  97. /**
  98. * @brief Get a file attribute
  99. * @details This function is a getter that allow you to retrieve various
  100. * informations about a file on a smb_stat object. You can get its size,
  101. * various timestamps, etc.
  102. *
  103. * @param info The smb_stat object to get info from.
  104. * @param what This parameter tells the functions which information to get, can
  105. * be one of #SMB_STAT_SIZE, #SMB_STAT_ALLOC_SIZE, #SMB_STAT_ISDIR,
  106. * #SMB_STAT_CTIME, #SMB_STAT_ATIME, #SMB_STAT_MTIME, #SMB_STAT_WTIME.
  107. *
  108. * @return The meaning of the returned value depends on the 'what' parameter.
  109. * See each item documentation.
  110. */
  111. uint64_t smb_stat_get(smb_stat info, int what);
  112. #endif