Files
geant4/source/analysis/g4tools/include/tools/signature
T
2016-06-10 12:08:39 +02:00

24 lines
532 B
Plaintext

// Copyright (C) 2010, Guy Barrand. All rights reserved.
// See the file tools.license for terms.
#ifndef tools_signature
#define tools_signature
#include <string>
#include <cstdio>
namespace tools {
namespace file {
inline bool signature(const std::string& a_file,unsigned char a_head[],unsigned int& a_num){ //it is assumed a_head[] can contain a_num chars.
FILE* file = ::fopen(a_file.c_str(),"rb");
if(!file) {a_num=0;return false;}
a_num = ::fread(a_head,1,a_num,file);
::fclose(file);
return true;
}
}}
#endif