diff options
author | Gabor X Toth <*@tg-x.net> | 2016-01-27 20:45:36 +0000 |
---|---|---|
committer | Gabor X Toth <*@tg-x.net> | 2016-01-27 20:45:36 +0000 |
commit | d4ffe9082fa632d5696611dc5977852cc6397bce (patch) | |
tree | 7148511969accd3d19fc1a534cf0814b4c01d7ad /src/social/gnunet-service-social.c | |
parent | 9a12525940373bd2616357e066fe59cb2ea08d8d (diff) | |
download | gnunet-d4ffe9082fa632d5696611dc5977852cc6397bce.tar.gz gnunet-d4ffe9082fa632d5696611dc5977852cc6397bce.zip |
social: save file
Diffstat (limited to 'src/social/gnunet-service-social.c')
-rw-r--r-- | src/social/gnunet-service-social.c | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/src/social/gnunet-service-social.c b/src/social/gnunet-service-social.c index 85679c63c..df9f2a395 100644 --- a/src/social/gnunet-service-social.c +++ b/src/social/gnunet-service-social.c | |||
@@ -914,7 +914,16 @@ place_recv_save_method (void *cls, | |||
914 | /* save if does not already exist */ | 914 | /* save if does not already exist */ |
915 | if (GNUNET_YES != GNUNET_DISK_file_test (filename)) | 915 | if (GNUNET_YES != GNUNET_DISK_file_test (filename)) |
916 | { | 916 | { |
917 | plc->file_save = GNUNET_YES; | 917 | if (0 == GNUNET_DISK_fn_write (filename, NULL, 0, |
918 | GNUNET_DISK_PERM_USER_READ | ||
919 | | GNUNET_DISK_PERM_USER_WRITE)) | ||
920 | { | ||
921 | plc->file_save = GNUNET_YES; | ||
922 | } | ||
923 | else | ||
924 | { | ||
925 | GNUNET_break (0); | ||
926 | } | ||
918 | } | 927 | } |
919 | GNUNET_free (filename); | 928 | GNUNET_free (filename); |
920 | } | 929 | } |
@@ -945,13 +954,20 @@ place_recv_save_data (void *cls, | |||
945 | GNUNET_DISK_directory_create_for_file (filename); | 954 | GNUNET_DISK_directory_create_for_file (filename); |
946 | struct GNUNET_DISK_FileHandle * | 955 | struct GNUNET_DISK_FileHandle * |
947 | fh = GNUNET_DISK_file_open (filename, GNUNET_DISK_OPEN_WRITE, | 956 | fh = GNUNET_DISK_file_open (filename, GNUNET_DISK_OPEN_WRITE, |
948 | GNUNET_DISK_PERM_USER_READ | 957 | GNUNET_DISK_PERM_NONE); |
949 | | GNUNET_DISK_PERM_USER_WRITE); | ||
950 | GNUNET_free (filename); | 958 | GNUNET_free (filename); |
951 | 959 | ||
952 | GNUNET_DISK_file_seek (fh, plc->file_offset, GNUNET_DISK_SEEK_SET); | 960 | if (NULL != fh) |
953 | GNUNET_DISK_file_write (fh, data, data_size); | 961 | { |
954 | GNUNET_DISK_file_close (fh); | 962 | GNUNET_DISK_file_seek (fh, plc->file_offset, GNUNET_DISK_SEEK_SET); |
963 | GNUNET_DISK_file_write (fh, data, data_size); | ||
964 | GNUNET_DISK_file_close (fh); | ||
965 | } | ||
966 | else | ||
967 | { | ||
968 | GNUNET_break (0); | ||
969 | } | ||
970 | |||
955 | plc->file_offset += data_size; | 971 | plc->file_offset += data_size; |
956 | } | 972 | } |
957 | 973 | ||