Get File Metadata in Linux

How to get metadata from a file in c

Did you try fstat()?

Man page link: https://linux.die.net/man/2/fstat

Get file metadata in Linux

You can use fc-query utility provided as part of fontconfig to get the information. fc-query on the .ttf file will provide you with lot of information. The information which you need can be obtained by getting the fullname of the ttf file. You can try fc-query <.ttf file> --format=%{fullname} man fc-query will give you more details regarding the same.

Hope this helps!

Get dll metadata in Linux environment

Using AssemblyMetadata from Microsoft.CodeAnalysis.Common package you can read the content of a dll like Version, Module, Type, Reference, Property, and pretty much everything

var path = @"path/to/dll/file.dll";
var metadata = AssemblyMetadata.CreateFromFile(path);
var module = metadata.GetModules().First();
Console.WriteLine(module.Name);

var reader = module.GetMetadataReader();

var assemblyDef = reader.GetAssemblyDefinition();
Console.WriteLine(reader.GetString(assemblyDef.Name));
Console.WriteLine(assemblyDef.Version.ToString());

foreach (var typeDefHandle in reader.TypeDefinitions)
{
var typeDef = reader.GetTypeDefinition(typeDefHandle);
var fullName = (reader.GetString(typeDef.Namespace) + "::" + reader.GetString(typeDef.Name));
Console.WriteLine(fullName);
}

How to get audio file metadata container's data for flac and ogg

Warning: One audio file can have multiple metadata containers. So finding vorbis comment doesn't mean there is no id3 tags. Reminder: flac and ogg should be used with vorbis comment.

Vorbis comment

Flac

metaflac --list myfile.flac

It will print a lot of info for each block. Here is the answer:

METADATA block #2
type: 4 (VORBIS_COMMENT)

To install metaflac: sudo apt install flac.

Ogg

vorbiscomment file.ogg

It will output something like:

encoder=Lavc57.107.100 libvorbis
TRACKNUMBER=1
title=My file title
...

To install: sudo apt install vorbis-tools

ID3

Well, the best thing I found is a python library: mutagen. For example, in your python file you can write:

from mutagen.id3 import ID3NoHeaderError, ID3

try:
tags = ID3("path/to/myfile.ogg")
print("ID3 tags found: ", tags)
except ID3NoHeaderError:
print("No ID3 tags")

Output for file with ID3 tags: ID3 tags found: {'TIT2': TIT2(encoding=<Encoding.UTF8: 3>, text=['my new title'])}. It works also for flac files.

How to get the file's meta data in kernel space - linux 3.5

I thought about the question some more.

There are filesystem-specific ways to create the possibility of truly hidden files, of course, but I'm not at all interested in exploring those. However, there is a different approach, a variant, that might suit your needs.

You could achieve a similar effect by intercepting only the open syscall (extending the existing one, to be precise). If the opened file resolves to a nonexisting file, but the directory and the file name match, instead of failing you construct a special path to the "hidden" file, and open that instead.

The existing file would then be a perfectly normal file, just actually somewhere else. Of course, you can put it in a root-only accessible directory (drwx------ root:root), and omit the access security check when opening it, to make it "hidden".



Related Topics



Leave a reply



Submit