Skip to content
This repository has been archived by the owner on Jul 30, 2021. It is now read-only.

无法获取文件信息(MD5,大小等) #3

Open
1 task done
Jasonzyt opened this issue Dec 11, 2020 · 1 comment
Open
1 task done

无法获取文件信息(MD5,大小等) #3

Jasonzyt opened this issue Dec 11, 2020 · 1 comment
Labels
bug Something isn't working 玄学bug 未知原因导致的bug

Comments

@Jasonzyt
Copy link
Member

Jasonzyt commented Dec 11, 2020

无法获取文件信息(MD5,大小等)

  • 严重性:高
  • 对功能的影响:备份
  • 受影响的版本:3.1.5及以下
  • BUG原因
// Functions.cpp
using namespace std;
size_t GetFileSizeByte(const std::string& file_name) 
{
	size_t size;
	FILE* file = fopen(file_name.c_str(), "rb");
	if (file)
	{
		size_t size = filelength(fileno(file));
		fclose(file);
		return size;
	}
	else
	{
		return -1;
	}
}
string GetFileSize(const std::string& file_name) 
{
	size_t size = 0;
	FILE* file = fopen(file_name.c_str(), "rb");
	if (file)
	{
		size_t size = filelength(fileno(file));
		fclose(file);
	}
	else
	{
		return "";
	}
    if (size >= 1024 && size < 1048576)
    {
        ostringstream a;
        a << size / 1024 << "KB";
        return a.str();
    }
    else if (size >= 1048576 && size < 1073741824)
    {
        ostringstream a;
        a << size / 1048576 << "MB";
        return a.str();
    }
    else if (size >=1073741824  && size < 1099511627776)
    {
        ostringstream a;
        a << size / 1073741824 << "GB";
        return a.str();
    }
    else
    {
        ostringstream a;
        a << size << "Byte";
        return a.str();
    }
}
// 插件模块.cpp
void writeJsons(string path, string opfn,string Operator)
{
    ...
    FILE *fp = fopen(path.c_str(), "wb+”);
    string md5 = md5file(fp);
    fclose(fp);
    ...
    string fs = GetFileSize(path);
    size_t fsb = GetFileSizeByte(path);
    ...
}
  • 修复
@Jasonzyt Jasonzyt added bug Something isn't working 玄学bug 未知原因导致的bug and removed bug Something isn't working labels Dec 11, 2020
@Jasonzyt
Copy link
Member Author

目前该BUG并未从根源解决
各位dalao可以看下

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working 玄学bug 未知原因导致的bug
Projects
None yet
Development

No branches or pull requests

1 participant