61 lines
1.3 KiB
C#
61 lines
1.3 KiB
C#
// Experimental code to open and dissect a `.deb` archive
|
|
|
|
static class DebArchive
|
|
{
|
|
const string DPKG_AR_MAGIC = "!<arch>\n";
|
|
const string DPKG_AR_FMAG = "`\n";
|
|
|
|
|
|
private static dpkg_ar dpkg_ar_fdopen(string filename, FileInfo fi)
|
|
{
|
|
return new dpkg_ar(
|
|
filename,
|
|
fi.UnixFileMode,
|
|
fi.Length,
|
|
fi.LastWriteTime,
|
|
fi);
|
|
}
|
|
|
|
private static dpkg_ar dpkg_ar_open(string filename)
|
|
{
|
|
FileInfo fi = new FileInfo(filename);
|
|
|
|
return dpkg_ar_fdopen(filename, fi);
|
|
}
|
|
}
|
|
|
|
sealed class dpkg_ar
|
|
{
|
|
string name;
|
|
UnixFileMode mode;
|
|
long size;
|
|
DateTime time;
|
|
FileInfo fi;
|
|
|
|
public dpkg_ar(string name,
|
|
UnixFileMode mode,
|
|
long size,
|
|
DateTime time,
|
|
FileInfo fi)
|
|
{
|
|
this.name = name;
|
|
this.mode = mode;
|
|
this.size = size;
|
|
this.time = time;
|
|
this.fi = fi;
|
|
}
|
|
}
|
|
|
|
/* TODO:
|
|
- Read the sourcecode for dpkg and find the c# equivalents
|
|
to extract an archive.
|
|
- If neccessary write a parser manually.
|
|
*/
|
|
/* NOTE:
|
|
- dpkg_ar is just FileInfo
|
|
- We might need to define dpkg_ar_hdr
|
|
- Pretty sure we can just find line ending in "`\n"
|
|
and parse that though. Split on (" ")
|
|
- Should then be able to read the files by streaming `size` bytes from the position after the and marker
|
|
*/
|