Skip to content

cjung95/DebFileManager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DebFileManager

A simple Debian package file manager for Linux systems.

Features

  • Read .deb files and list their contents, including file names, sizes, permissions, and ownership.
  • Provides a read-only stream interface for accessing files within a .deb package.

Usage

Here's an example of how to extract all files from a .deb file.

// Import the Jung.DebFileManager namespace
using Jung.DebFileManager;

// Create an instance of the DebFile
var debFile = new DebFile("C:\\path\\to\\file.deb");
// Iterate though the files contained in the .deb file
foreach(var item in debFile.Items)
{
    // Get the stream of the item
    var stream = debFile.GetDebFileItemStream(item);
    // create a file stream to save the file
    var fileStream = new FileStream(basePath + "\\" + item.FileName, FileMode.Create, FileAccess.Write);
    // copy the item to the file stream
    stream.CopyTo(fileStream);
    // close the file stream
    fileStream.Close();
}

You can also use the stream as the source for the SharpCompress library to directly access files within the compressed archives contained in the .deb file.

// Import the Jung.DebFileManager namespace
using Jung.DebFileManager;
using SharpCompress.Common;
using SharpCompress.Readers;

// Create an instance of the DebFile
var debFile = new DebFile("C:\\path\\to\\file.deb");
// Iterate though the files contained in the .deb file
foreach(var item in debFile.Items)
{
    // Get the stream of the item
    var stream = debFile.GetDebFileItemStream(item);
    try
    {
        using (var reader = ReaderFactory.Open(stream))
        {
            while (reader.MoveToNextEntry())
            {
                // Do something with the file
            }
        }
    }
    catch (InvalidFormatException)
    {
        // This stream is not a valid archive, skip it
    }
}

About

A library to manage deb files in C#.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages