Crate framels

Source
Expand description

§framels

framels is a library and a binary to list files and directorys like ls style and return a packed sequence of files. This lib is industry oriented for Animation and VFX, using a lot a frames sequences. The main objective is to be the fastest as possible using rustlang.

§Key concept

The key concept of the library is to pack frames sequences in a new filename like toto.***.jpg@158-179. It use a regex to extract the frame number and pack the frames. The regex is (?x)(.*)(\.|_)(?P<frames>\d{2,9})\.(\w{2,5})$. It results in the limitations of only:

  • . or _ as a separator between the filename and the frame number.
  • 2 to 9 digits for the frame number.
  • 2 to 5 characters for the extension.
  • The frame number must be at the end of the filename.
  • The frame number must be a number.
  • The frame number must be a positive number.
  • There is not filetering in the extension.

§Command line

framels is also a command line tool to list directory and pack frames in sequences. It’s a bit like ls but for frames sequences. You can use the short cut fls to call the binary.

§Example

In this example we use the recursive option to list all the files in the directory and subdirectory.

$ fls --recursive ./samples/small
./samples/small
./samples/small/aaa.***.tif@1-5
./samples/small/foo_bar.ex

§Library

The library is the core of the binary, it’s a rust library to list directory and pack frames in sequences.

§listing content of directories

§parse_dir

The parse_dir function list files and directories in the targeted directory, take a String as input and return a Paths of the entries. It use std::fs::ReadDir, nothing much.

§recursive_dir

The recursive_dir function list files and directories in the targeted directory, take a String as inut and return a Paths of the entries recursively. It use jwalk as the core of the parsing. It is really efficiant with a lot of directories.

§pack frames

The library is really simple to use, you can use the basic_listing or extended_listing function to list directory and pack frames in sequences.

The frame packing algorithm got a optimization when the amount of listed files is bigger than 100 000 files.

§basic_listing

The basic_listing function is the main function of the library it use a list of filename as in input and pack the frame sequences using a new filename like toto.***.jpg@158-179

§extended_listing

The extended_listing function is specialize to analyse exr frames really similar to rvls -l It take a Vec<String> of entries as an input

  • Pack the frames
  • Print the metada if the sequence is an exr sequence
  • Return a Vector of path packed

§Example

use framels::{basic_listing, extended_listing, parse_dir, paths::{Paths,Join}, recursive_dir};

fn main() {
   // Perform directory listing
  let in_paths: Paths = parse_dir("./samples/small");

 // Generate results based on arguments
let results: String = basic_listing(in_paths, false).get_paths().join("\n");

println!("{}", results)
}

Modules§

paths
paths module is handle the Paths and PathsPacked types

Functions§

basic_listing
basic_listing
extended_listing
extended_listing
parse_dir
parse_dir
recursive_dir
Recursive walking