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



524
525
# File 'docs/0_Dependencies.rb', line 524

def initialize(filename, mode)
end

Instance Attribute Details

#filenameString (readonly)

Returns the filename of the current Yuki::VD.

Returns:

  • (String)

    the filename of the current Yuki::VD



509
510
511
# File 'docs/0_Dependencies.rb', line 509

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



544
545
# File 'docs/0_Dependencies.rb', line 544

def add_file(filename, ext_name = nil)
end

#close

Close the VD



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

def close
end

#exists?(filename) ⇒ Boolean

Test if a file exists in the VD

Parameters:

Returns:

  • (Boolean)


534
535
# File 'docs/0_Dependencies.rb', line 534

def exists?(filename)
end

#get_filenamesArray<String>

Get all the filename

Returns:



548
549
# File 'docs/0_Dependencies.rb', line 548

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



529
530
# File 'docs/0_Dependencies.rb', line 529

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



539
540
# File 'docs/0_Dependencies.rb', line 539

def write_data(filename, data)
end