Created
August 15, 2013 15:32
-
-
Save inohiro/6241797 to your computer and use it in GitHub Desktop.
Detect fbx format (Binary one or ASCII one) with ruby
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FILE_PATH = File.expand_path './file.fbx' | |
CORRECT = %w"K a y d a r a \ F B X \ B i n a r y \ \ " | |
def binary_fbx? file_path | |
File.open( file_path, 'rb' ) do |file| | |
CORRECT.each do |char| | |
num = file.read( 1 ) | |
false if num != char | |
end | |
false if file.read( 1 ) != "\x00" | |
false if file.read( 2 ) != "\x1A\x00" # Byte 21-22 | |
# version = file.read( 4 ) # Byte 23-26 | |
# int_version = version.unpack("L") # 32 bit integer | |
true | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment