1.1 --- a/libfsserver/lib/files/block_file_accessor.cc Thu Apr 22 00:12:16 2021 +0200
1.2 +++ b/libfsserver/lib/files/block_file_accessor.cc Sat Apr 24 23:15:21 2021 +0200
1.3 @@ -30,14 +30,14 @@
1.4
1.5
1.6
1.7 -BlockFileAccessor::BlockFileAccessor(const char *path, fileid_t fileid)
1.8 -: Accessor(fileid)
1.9 +BlockFileAccessor::BlockFileAccessor(FILE *fp, fileid_t fileid)
1.10 +: Accessor(fileid), _fp(fp)
1.11 {
1.12 /* Obtain the size of the file. */
1.13
1.14 struct stat buf;
1.15
1.16 - if (stat(path, &buf))
1.17 + if (fstat(fileno(fp), &buf))
1.18 {
1.19 _size = 0;
1.20 return;
1.21 @@ -53,17 +53,7 @@
1.22
1.23 /* Load the file into memory and initialise the size. */
1.24
1.25 - FILE *fp = fopen(path, "r");
1.26 -
1.27 - if (fp == NULL)
1.28 - {
1.29 - free(_data);
1.30 - return;
1.31 - }
1.32 -
1.33 _size = fread(_data, sizeof(char), _size, fp);
1.34 -
1.35 - fclose(fp);
1.36 }
1.37
1.38 /* Return the size of the file. */