lib/co-kamishibai/functions.rb
# returns total number of pages for cbz file, and save bookmarks
returns total number of pages for cbz file, and save bookmarks
returns total number of pages for cbz file and save bookmarks
def cbz_pages?( zfile )
  bcbz = File.basename( zfile )
  if $bookmarks[ bcbz ]
    return $bookmarks[ bcbz ][1]
  end
  objs = []
  Zip::File.open( zfile ) { |x|
    x.each { |i|
      if i.ftype == :file and File.basename( i.name ) =~ /^[^.].+?\.(jpg|jpeg|png|gif)$/i
        objs << i
      end
    }
  }
  while true
    word = GenID(3)
    break unless $bookcodes.include?(word) 
  end
  $bookmarks[ bcbz ] = [ 1, objs.length, word ]
  $bookcodes << word
  $bookmarks_dirty = true
  return objs.length
end
def cbz_pages? ( zfile ) bcbz = File . basename ( zfile ) if $bookmarks [ bcbz ] return $bookmarks [ bcbz ] [ 1 ] end objs = [ ] Zip :: File . open ( zfile ) { | x | x . each { | i | if i . ftype == :file and File . basename ( i . name ) =~ / ^[^.].+? \. (jpg|jpeg|png|gif)$ /i objs << i end } } while true word = GenID ( 3 ) break unless $bookcodes . include? ( word ) end $bookmarks [ bcbz ] = [ 1 , objs . length , word ] $bookcodes << word $bookmarks_dirty = true return objs . length end
returns total number of pages for cbz file, and save bookmarks
returns total number of pages for cbz file and save bookmarks
# generate a unique bookcode, lookup bookcode existance by using db # find next available word #puts "#{word} - #{f}"
zfile