2023-07-24 19:19:21 -07:00
|
|
|
Code scan_file( char const* path )
|
|
|
|
{
|
|
|
|
FileInfo file;
|
|
|
|
|
|
|
|
FileError error = file_open_mode( & file, EFileMode_READ, path );
|
|
|
|
if ( error != EFileError_NONE )
|
|
|
|
{
|
2023-08-09 15:47:59 -07:00
|
|
|
GEN_FATAL( "scan_file: Could not open: %s", path );
|
2023-07-24 19:19:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
sw fsize = file_size( & file );
|
|
|
|
if ( fsize <= 0 )
|
|
|
|
{
|
2023-08-09 15:47:59 -07:00
|
|
|
GEN_FATAL("scan_file: %s is empty", path );
|
2023-07-24 19:19:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
String str = String::make_reserve( GlobalAllocator, fsize );
|
|
|
|
file_read( & file, str, fsize );
|
|
|
|
str.get_header().Length = fsize;
|
|
|
|
|
|
|
|
file_close( & file );
|
|
|
|
|
|
|
|
return untyped_str( str );
|
|
|
|
}
|
|
|
|
|
2023-08-03 20:18:33 -07:00
|
|
|
#if 0
|
2023-07-24 19:19:21 -07:00
|
|
|
struct Policy
|
|
|
|
{
|
|
|
|
// Nothing for now.
|
|
|
|
};
|
2023-07-18 20:33:00 -07:00
|
|
|
|
|
|
|
struct SymbolInfo
|
|
|
|
{
|
|
|
|
StringCached File;
|
|
|
|
char const* Marker;
|
|
|
|
Code Signature;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Scanner
|
|
|
|
{
|
|
|
|
struct RequestEntry
|
|
|
|
{
|
|
|
|
SymbolInfo Info;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Receipt
|
|
|
|
{
|
|
|
|
StringCached File;
|
|
|
|
Code Defintion;
|
|
|
|
bool Result;
|
|
|
|
};
|
|
|
|
|
|
|
|
AllocatorInfo MemAlloc;
|
|
|
|
|
|
|
|
static void set_allocator( AllocatorInfo allocator );
|
|
|
|
|
2023-07-19 20:42:28 -07:00
|
|
|
Array<FileInfo> Files;
|
2023-07-18 20:33:00 -07:00
|
|
|
String Buffer;
|
2023-07-19 20:42:28 -07:00
|
|
|
Array<RequestEntry> Requests;
|
2023-07-18 20:33:00 -07:00
|
|
|
|
|
|
|
void add_files( s32 num, char const** files );
|
|
|
|
|
|
|
|
void add( SymbolInfo signature, Policy policy );
|
|
|
|
|
2023-07-19 20:42:28 -07:00
|
|
|
bool process_requests( Array<Receipt> out_receipts );
|
2023-07-18 20:33:00 -07:00
|
|
|
};
|
2023-08-03 20:18:33 -07:00
|
|
|
#endif
|
2023-07-19 20:42:28 -07:00
|
|
|
|