1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen#ifndef MDBOX_FILE_H
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen#define MDBOX_FILE_H
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen#include "dbox-file.h"
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainenstruct mdbox_file {
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen struct dbox_file file;
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen struct mdbox_storage *storage;
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen uint32_t file_id;
04c3ac276103b56185119bcff9a66de7a8bb0e68Timo Sirainen time_t close_time;
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen};
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainenstruct dbox_file *
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainenmdbox_file_init(struct mdbox_storage *storage, uint32_t file_id);
9955f6cba7652469b1d600a3674e8d27dd4e61bdTimo Sirainenstruct dbox_file *
9955f6cba7652469b1d600a3674e8d27dd4e61bdTimo Sirainenmdbox_file_init_new_alt(struct mdbox_storage *storage);
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen/* Assign file ID for a newly created file. */
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainenint mdbox_file_assign_file_id(struct mdbox_file *file, uint32_t file_id);
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainenvoid mdbox_file_unrefed(struct dbox_file *file);
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainenint mdbox_file_create_fd(struct dbox_file *file, const char *path,
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen bool parents);
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainenvoid mdbox_files_free(struct mdbox_storage *storage);
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainenvoid mdbox_files_sync_input(struct mdbox_storage *storage);
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen#endif