判定コード例
SIGNATURE = bytes.fromhex("706c790a")
OFFSET = 0
def is_ply(path: str) -> bool:
with open(path, "rb") as f:
f.seek(OFFSET)
head = f.read(len(SIGNATURE))
return head == SIGNATURE
const SIGNATURE = [0x70, 0x6c, 0x79, 0x0a];
const OFFSET = 0;
// bytes: a Uint8Array / Buffer holding the start of the file
export function isPly(bytes) {
return SIGNATURE.every((byte, i) => bytes[OFFSET + i] === byte);
}
package fileid
import "bytes"
var isplySignature = []byte{0x70, 0x6c, 0x79, 0x0a}
const isplyOffset = 0
func IsPly(b []byte) bool {
end := isplyOffset + len(isplySignature)
if len(b) < end {
return false
}
return bytes.Equal(b[isplyOffset:end], isplySignature)
}
const SIGNATURE: &[u8] = &[0x70, 0x6c, 0x79, 0x0a];
const OFFSET: usize = 0;
fn is_ply(bytes: &[u8]) -> bool {
bytes.get(OFFSET..OFFSET + SIGNATURE.len()) == Some(SIGNATURE)
}
<?php
$signature = "\x70\x6c\x79\x0a";
$offset = 0;
function is_ply(string $bytes): bool {
global $signature, $offset;
return substr($bytes, $offset, strlen($signature)) === $signature;
}