Hi All,
I have some files to process and they are named as xxx.db.
Some are gds files. and some are oasis files.
Some files are very large, 2G maybe.
I only want to know the file type,
so I think we don't need to load it all, just read head info maybe.
How to write a script to report the file type quickly?
Comments
Hi,
it's entirely sufficient to read the first few bytes. OASIS and GDS have a specific signature.
I'll give you more details if you like.
Matthias
Hi dion,
here are the details:
KLayout detects the file format looking at the first four bytes:
The Linux "file" tool is able to detect GDS2 and OASIS files as well (I have tried version 5.14), so on Linux it's very simple to scan the file types within a shell script.
Matthias
Thanks for your reply.
We use old linux (centos 4.6) with file version 4.10, which could not detect OASIS.
However, I add API for klayout to report file type before reading the stream.
extern std::string stream_format(const std::string &filename)
{
tl::InputStream stream (filename);
db::Reader reader (stream);
return reader.format();
}
Then call it in python, it worked.
Thanks,
Dion