WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Affero General Public License for more details.
-*/
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ SPDX-License-Identifier: AGPL3.0-or-later
+ */
/**
* @file fs/fs_file_information.c
return s->serialization;
}
+
/**
* Obtain the filename from the file information structure.
*
* @return publish structure entry for the file
*/
struct GNUNET_FS_FileInformation *
-GNUNET_FS_file_information_create_from_file (struct GNUNET_FS_Handle *h,
- void *client_info,
- const char *filename,
- const struct GNUNET_FS_Uri
- *keywords,
- const struct
- GNUNET_CONTAINER_MetaData *meta,
- int do_index,
- const struct GNUNET_FS_BlockOptions
- *bo)
+GNUNET_FS_file_information_create_from_file (
+ struct GNUNET_FS_Handle *h,
+ void *client_info,
+ const char *filename,
+ const struct GNUNET_FS_Uri *keywords,
+ const struct GNUNET_CONTAINER_MetaData *meta,
+ int do_index,
+ const struct GNUNET_FS_BlockOptions *bo)
{
struct FileInfo *fi;
uint64_t fsize;
const char *fn;
const char *ss;
-#if WINDOWS
- char fn_conv[MAX_PATH];
-#endif
-
/* FIXME: should include_symbolic_links be GNUNET_NO or GNUNET_YES here? */
- if (GNUNET_OK != GNUNET_DISK_file_size (filename, &fsize, GNUNET_NO, GNUNET_YES))
+ if (GNUNET_OK !=
+ GNUNET_DISK_file_size (filename, &fsize, GNUNET_NO, GNUNET_YES))
{
GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "stat", filename);
return NULL;
return NULL;
}
ret =
- GNUNET_FS_file_information_create_from_reader (h, client_info,
- fsize,
- &GNUNET_FS_data_reader_file_,
- fi, keywords, meta,
- do_index, bo);
+ GNUNET_FS_file_information_create_from_reader (h,
+ client_info,
+ fsize,
+ &GNUNET_FS_data_reader_file_,
+ fi,
+ keywords,
+ meta,
+ do_index,
+ bo);
if (ret == NULL)
return NULL;
ret->h = h;
ret->filename = GNUNET_strdup (filename);
-#if !WINDOWS
fn = filename;
-#else
- plibc_conv_to_win_path (filename, fn_conv);
- fn = fn_conv;
-#endif
while (NULL != (ss = strstr (fn, DIR_SEPARATOR_STR)))
fn = ss + 1;
/* FIXME: If we assume that on other platforms CRT is UTF-8-aware, then
* this should be changed to EXTRACTOR_METAFORMAT_UTF8
*/
-#if !WINDOWS
- GNUNET_CONTAINER_meta_data_insert (ret->meta, "<gnunet>",
+ GNUNET_CONTAINER_meta_data_insert (ret->meta,
+ "<gnunet>",
EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME,
EXTRACTOR_METAFORMAT_C_STRING,
- "text/plain", fn, strlen (fn) + 1);
-#else
- GNUNET_CONTAINER_meta_data_insert (ret->meta, "<gnunet>",
- EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain", fn, strlen (fn) + 1);
-#endif
+ "text/plain",
+ fn,
+ strlen (fn) + 1);
return ret;
}
* @return publish structure entry for the file
*/
struct GNUNET_FS_FileInformation *
-GNUNET_FS_file_information_create_from_data (struct GNUNET_FS_Handle *h,
- void *client_info, uint64_t length,
- void *data,
- const struct GNUNET_FS_Uri
- *keywords,
- const struct
- GNUNET_CONTAINER_MetaData *meta,
- int do_index,
- const struct GNUNET_FS_BlockOptions
- *bo)
+GNUNET_FS_file_information_create_from_data (
+ struct GNUNET_FS_Handle *h,
+ void *client_info,
+ uint64_t length,
+ void *data,
+ const struct GNUNET_FS_Uri *keywords,
+ const struct GNUNET_CONTAINER_MetaData *meta,
+ int do_index,
+ const struct GNUNET_FS_BlockOptions *bo)
{
if (GNUNET_YES == do_index)
{
GNUNET_break (0);
return NULL;
}
- return GNUNET_FS_file_information_create_from_reader (h, client_info, length,
- &GNUNET_FS_data_reader_copy_,
- data, keywords, meta,
- do_index, bo);
+ return GNUNET_FS_file_information_create_from_reader (h,
+ client_info,
+ length,
+ &
+ GNUNET_FS_data_reader_copy_,
+ data,
+ keywords,
+ meta,
+ do_index,
+ bo);
}
* @return publish structure entry for the file
*/
struct GNUNET_FS_FileInformation *
-GNUNET_FS_file_information_create_from_reader (struct GNUNET_FS_Handle *h,
- void *client_info,
- uint64_t length,
- GNUNET_FS_DataReader reader,
- void *reader_cls,
- const struct GNUNET_FS_Uri
- *keywords,
- const struct
- GNUNET_CONTAINER_MetaData *meta,
- int do_index,
- const struct
- GNUNET_FS_BlockOptions *bo)
+GNUNET_FS_file_information_create_from_reader (
+ struct GNUNET_FS_Handle *h,
+ void *client_info,
+ uint64_t length,
+ GNUNET_FS_DataReader reader,
+ void *reader_cls,
+ const struct GNUNET_FS_Uri *keywords,
+ const struct GNUNET_CONTAINER_MetaData *meta,
+ int do_index,
+ const struct GNUNET_FS_BlockOptions *bo)
{
struct GNUNET_FS_FileInformation *ret;
* @return #GNUNET_YES if so, #GNUNET_NO if not
*/
int
-GNUNET_FS_file_information_is_directory (const struct GNUNET_FS_FileInformation
- *ent)
+GNUNET_FS_file_information_is_directory (
+ const struct GNUNET_FS_FileInformation *ent)
{
return ent->is_directory;
}
* @return publish structure entry for the directory , NULL on error
*/
struct GNUNET_FS_FileInformation *
-GNUNET_FS_file_information_create_empty_directory (struct GNUNET_FS_Handle *h,
- void *client_info,
- const struct GNUNET_FS_Uri
- *keywords,
- const struct
- GNUNET_CONTAINER_MetaData
- *meta,
- const struct
- GNUNET_FS_BlockOptions *bo,
- const char *filename)
+GNUNET_FS_file_information_create_empty_directory (
+ struct GNUNET_FS_Handle *h,
+ void *client_info,
+ const struct GNUNET_FS_Uri *keywords,
+ const struct GNUNET_CONTAINER_MetaData *meta,
+ const struct GNUNET_FS_BlockOptions *bo,
+ const char *filename)
{
struct GNUNET_FS_FileInformation *ret;
GNUNET_FS_file_information_add (struct GNUNET_FS_FileInformation *dir,
struct GNUNET_FS_FileInformation *ent)
{
- if ((ent->dir != NULL) || (ent->next != NULL) || (dir->is_directory != GNUNET_YES))
+ if ((ent->dir != NULL) || (ent->next != NULL) ||
+ (dir->is_directory != GNUNET_YES))
{
GNUNET_break (0);
return GNUNET_SYSERR;
no = GNUNET_NO;
if (GNUNET_OK !=
- proc (proc_cls, dir,
- (dir->is_directory == GNUNET_YES) ? dir->data.dir.dir_size : dir->data.
- file.file_size,
- dir->meta, &dir->keywords, &dir->bo,
+ proc (proc_cls,
+ dir,
+ (dir->is_directory == GNUNET_YES) ? dir->data.dir.dir_size
+ : dir->data.file.file_size,
+ dir->meta,
+ &dir->keywords,
+ &dir->bo,
(dir->is_directory == GNUNET_YES) ? &no : &dir->data.file.do_index,
&dir->client_info))
return;
{
no = GNUNET_NO;
if (GNUNET_OK !=
- proc (proc_cls, pos,
- (pos->is_directory == GNUNET_YES) ? pos->data.dir.dir_size : pos->data.
- file.file_size, pos->meta, &pos->keywords, &pos->bo,
- (pos->is_directory == GNUNET_YES) ? &no : &pos->data.file.do_index,
+ proc (proc_cls,
+ pos,
+ (pos->is_directory == GNUNET_YES) ? pos->data.dir.dir_size
+ : pos->data.file.file_size,
+ pos->meta,
+ &pos->keywords,
+ &pos->bo,
+ (pos->is_directory == GNUNET_YES) ? &no
+ : &pos->data.file.do_index,
&pos->client_info))
break;
pos = pos->next;
}
/* clean up client-info */
if (NULL != cleaner)
- cleaner (cleaner_cls, fi, fi->data.dir.dir_size, fi->meta, &fi->keywords,
- &fi->bo, &no, &fi->client_info);
+ cleaner (cleaner_cls,
+ fi,
+ fi->data.dir.dir_size,
+ fi->meta,
+ &fi->keywords,
+ &fi->bo,
+ &no,
+ &fi->client_info);
GNUNET_free_non_null (fi->data.dir.dir_data);
}
else
}
/* clean up client-info */
if (NULL != cleaner)
- cleaner (cleaner_cls, fi, fi->data.file.file_size, fi->meta,
- &fi->keywords, &fi->bo, &fi->data.file.do_index,
+ cleaner (cleaner_cls,
+ fi,
+ fi->data.file.file_size,
+ fi->meta,
+ &fi->keywords,
+ &fi->bo,
+ &fi->data.file.do_index,
&fi->client_info);
}
GNUNET_free_non_null (fi->filename);
GNUNET_free_non_null (fi->emsg);
if (NULL != fi->sks_uri)
- GNUNET_FS_uri_destroy (fi->sks_uri);
+ GNUNET_FS_uri_destroy (fi->sks_uri);
if (NULL != fi->chk_uri)
- GNUNET_FS_uri_destroy (fi->chk_uri);
+ GNUNET_FS_uri_destroy (fi->chk_uri);
/* clean up serialization */
- if ((NULL != fi->serialization) && (0 != UNLINK (fi->serialization)))
- GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink",
+ if ((NULL != fi->serialization) && (0 != unlink (fi->serialization)))
+ GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING,
+ "unlink",
fi->serialization);
if (NULL != fi->keywords)
GNUNET_FS_uri_destroy (fi->keywords);