Class: Yuki::VD

Inherits:
Object show all
Defined in:
docs/0_Dependencies.rb

Overview

Class that helps to read Virtual Directories

In reading mode, the Virtual Directories can be loaded to RAM if MAX_SIZE >= VD.size

All the filenames inside the Yuki::VD has to be downcased filename in utf-8

Note : Encryption is up to the developper and no longer supported on the basic script

Constant Summary collapse

DEBUG_ON =

Is the debug info on ?

ARGV.include?('debug-yuki-vd')
MAX_SIZE =

The max size of the file that can be loaded in memory

10 * 1024 * 1024
ALLOWED_MODES =

10Mo List of allowed modes

%i[read write update]
POINTER_SIZE =

Size of the pointer at the begin of the file

4
UNPACK_METHOD =

Unpack method of the pointer at the begin of the file

'L'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename, mode) ⇒ VD

Create a new Yuki::VD file or load it

Parameters:

  • filename (String) —

    name of the Yuki::VD file

  • mode (:read, :write, :update) —

    if we read or write the virtual directory



541
542
# File 'docs/0_Dependencies.rb', line 541

def initialize(filename, mode)
end

Instance Attribute Details

#filename ⇒ String (readonly)

Returns the filename of the current Yuki::VD.

Returns:

  • (String) —

    the filename of the current Yuki::VD



526
527
528
# File 'docs/0_Dependencies.rb', line 526

def filename
  @filename
end

Instance Method Details

#add_file(filename, ext_name = nil)

Add a file to the Yuki::VD

Parameters:

  • filename (String) —

    the file name

  • ext_name (String, nil) (defaults to: nil) —

    the file extension



561
562
# File 'docs/0_Dependencies.rb', line 561

def add_file(filename, ext_name = nil)
end

#close

Close the VD



568
569
# File 'docs/0_Dependencies.rb', line 568

def close
end

#exists?(filename) ⇒ Boolean

Test if a file exists in the VD

Parameters:

Returns:

  • (Boolean)


551
552
# File 'docs/0_Dependencies.rb', line 551

def exists?(filename)
end

#get_filenames ⇒ Array<String>

Get all the filename

Returns:



565
566
# File 'docs/0_Dependencies.rb', line 565

def get_filenames
end

#read_data(filename) ⇒ String?

Read a file data from the VD

Parameters:

  • filename (String) —

    the file we want to read its data

Returns:

  • (String, nil) —

    the data of the file



546
547
# File 'docs/0_Dependencies.rb', line 546

def read_data(filename)
end

#write_data(filename, data)

Write a file with its data in the VD

Parameters:

  • filename (String) —

    the file name

  • data (String) —

    the data of the file



556
557
# File 'docs/0_Dependencies.rb', line 556

def write_data(filename, data)
end