00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00036 #ifndef _core_fileinfo_h_
00037 #define _core_fileinfo_h_
00038
00039 #include "share.h"
00040 #include "if/core/fileinfo.h"
00041
00042
00043
00044
00045
00046 #define FI_LOW_SRC_COUNT 5
00048
00049
00050
00051
00052 #define FI_F_SUSPEND 0x00000001U
00053 #define FI_F_DISCARD 0x00000002U
00054 #define FI_F_TRANSIENT 0x40000000U
00055 #define FI_F_MARK 0x80000000U
00057
00058
00059
00060
00061 void file_info_init(void);
00062 void file_info_init_post(void);
00063 void file_info_scandir(const gchar *dir);
00064 gboolean file_info_has_trailer(const gchar *path);
00065 void file_info_retrieve(void);
00066 void file_info_store(void);
00067 void file_info_store_binary(fileinfo_t *fi);
00068 void file_info_store_if_dirty(void);
00069 void file_info_set_discard(fileinfo_t *fi, gboolean state);
00070 enum dl_chunk_status file_info_find_hole(
00071 struct download *d, filesize_t *from, filesize_t *to);
00072 gboolean file_info_find_available_hole(struct download *d,
00073 GSList *ranges, filesize_t *from, filesize_t *to);
00074 void file_info_merge_adjacent(fileinfo_t *fi);
00075 void file_info_clear_download(struct download *d, gboolean lifecount);
00076 enum dl_chunk_status file_info_chunk_status(
00077 fileinfo_t *fi, filesize_t from, filesize_t to);
00078 void file_info_reset(fileinfo_t *fi);
00079 void file_info_recreate(struct download *d);
00080 fileinfo_t *file_info_get(
00081 gchar *file, const gchar *path, filesize_t size, gchar *sha1,
00082 gboolean file_size_known);
00083 void file_info_strip_binary(fileinfo_t *fi);
00084 void file_info_strip_binary_from_file(fileinfo_t *fi, const gchar *file);
00085 gboolean file_info_got_sha1(fileinfo_t *fi, const gchar *sha1);
00086 void file_info_size_known(struct download *d, filesize_t size);
00087 void file_info_update(struct download *d, filesize_t from, filesize_t to,
00088 enum dl_chunk_status status);
00089 enum dl_chunk_status file_info_pos_status(fileinfo_t *fi,
00090 filesize_t pos );
00091 void file_info_close(void);
00092 void file_info_close_pre(void);
00093 void file_info_try_to_swarm_with(
00094 gchar *file_name, guint32 idx, const host_addr_t addr,
00095 guint16 port, gchar *sha1);
00096 void file_info_spot_completed_orphans(void);
00097 void file_info_add_source(fileinfo_t *fi, struct download *dl);
00098 void file_info_add_new_source(fileinfo_t *fi, struct download *dl);
00099 void file_info_remove_source(
00100 fileinfo_t *fi, struct download *dl, gboolean discard);
00101 void file_info_timer(void);
00102 void file_info_unlink(fileinfo_t *fi);
00103 void file_info_upload_stop(fileinfo_t *fi, const gchar *reason);
00104 void file_info_changed(fileinfo_t *fi);
00105
00106 shared_file_t *file_info_shared_sha1(const gchar *sha1);
00107 gint file_info_available_ranges(fileinfo_t *fi, gchar *buf, gint size);
00108 gboolean file_info_restrict_range(
00109 fileinfo_t *fi, filesize_t start, filesize_t *end);
00110
00111 fileinfo_t *file_info_has_identical(
00112 gchar *file, filesize_t size, gchar *sha1);
00113
00114 fileinfo_t *file_info_get_browse(const gchar *name);
00115 void file_info_remove(fileinfo_t *fi);
00116
00117
00118
00119
00120
00124 static inline G_GNUC_CONST WARN_UNUSED_RESULT guint32
00125 fi_alive_count(fileinfo_t *fi)
00126 {
00127 return fi->aqueued_count + fi->pqueued_count + fi->recvcount;
00128 }
00129
00130 #endif
00131
00132