2014-08-25 10:18:34 +00:00
|
|
|
/*
|
2014-05-06 14:23:05 +00:00
|
|
|
* s3fs - FUSE-based file system backed by Amazon S3
|
|
|
|
*
|
2017-05-07 11:24:17 +00:00
|
|
|
* Copyright(C) 2007 Randy Rizun <rrizun@gmail.com>
|
2014-05-06 14:23:05 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
2019-07-12 10:33:53 +00:00
|
|
|
#include <cstdio>
|
2014-05-06 14:23:05 +00:00
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include "s3fs_auth.h"
|
2015-08-19 18:22:30 +00:00
|
|
|
#include "string_util.h"
|
2014-05-06 14:23:05 +00:00
|
|
|
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
// Utility Function
|
|
|
|
//-------------------------------------------------------------------
|
2020-09-11 09:37:24 +00:00
|
|
|
std::string s3fs_get_content_md5(int fd)
|
2014-05-06 14:23:05 +00:00
|
|
|
{
|
2023-08-05 00:36:22 +00:00
|
|
|
md5_t md5;
|
|
|
|
if(!s3fs_md5_fd(fd, 0, -1, &md5)){
|
2023-08-06 13:22:02 +00:00
|
|
|
// TODO: better return value?
|
2023-08-17 13:12:28 +00:00
|
|
|
return "";
|
2020-08-22 12:40:53 +00:00
|
|
|
}
|
2023-08-06 13:22:02 +00:00
|
|
|
return s3fs_base64(md5.data(), md5.size());
|
2014-05-06 14:23:05 +00:00
|
|
|
}
|
|
|
|
|
2020-09-14 10:00:09 +00:00
|
|
|
std::string s3fs_sha256_hex_fd(int fd, off_t start, off_t size)
|
2015-01-20 16:31:36 +00:00
|
|
|
{
|
2023-08-05 00:36:22 +00:00
|
|
|
sha256_t sha256;
|
2015-01-20 16:31:36 +00:00
|
|
|
|
2023-08-05 00:36:22 +00:00
|
|
|
if(!s3fs_sha256_fd(fd, start, size, &sha256)){
|
2023-08-17 13:12:28 +00:00
|
|
|
// TODO: better return value?
|
|
|
|
return "";
|
2020-08-22 12:40:53 +00:00
|
|
|
}
|
2015-01-20 16:31:36 +00:00
|
|
|
|
2023-08-05 00:36:22 +00:00
|
|
|
std::string sha256hex = s3fs_hex_lower(sha256.data(), sha256.size());
|
2015-01-20 16:31:36 +00:00
|
|
|
|
2020-09-14 10:00:09 +00:00
|
|
|
return sha256hex;
|
2015-01-20 16:31:36 +00:00
|
|
|
}
|
|
|
|
|
2014-09-07 15:08:27 +00:00
|
|
|
/*
|
|
|
|
* Local variables:
|
2020-08-22 12:40:53 +00:00
|
|
|
* tab-width: 4
|
|
|
|
* c-basic-offset: 4
|
2014-09-07 15:08:27 +00:00
|
|
|
* End:
|
2020-08-22 12:40:53 +00:00
|
|
|
* vim600: expandtab sw=4 ts=4 fdm=marker
|
|
|
|
* vim<600: expandtab sw=4 ts=4
|
2014-09-07 15:08:27 +00:00
|
|
|
*/
|