https://github.com/michal-josef-spacek/cad-autocad-detect
Detect AutoCAD files through magic string.
https://github.com/michal-josef-spacek/cad-autocad-detect
Last synced: 2 months ago
JSON representation
Detect AutoCAD files through magic string.
- Host: GitHub
- URL: https://github.com/michal-josef-spacek/cad-autocad-detect
- Owner: michal-josef-spacek
- License: bsd-2-clause
- Created: 2020-04-06T09:45:00.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2024-01-01T21:59:56.000Z (over 1 year ago)
- Last Synced: 2025-01-01T04:47:20.527Z (4 months ago)
- Language: Perl
- Size: 60.5 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README
- Changelog: Changes
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
NAME
CAD::AutoCAD::Detect - Detect AutoCAD files through magic string.SYNOPSIS
use CAD::AutoCAD::Detect qw(detect_dwg_file);my $dwg_magic = detect_dwg_file($file);
DESCRIPTION
This Perl module detect AutoCAD files through magic string.List of supported files: dwg
SUBROUTINES
"detect_dwg_file"
my $dwg_magic = detect_dwg_file($file);Detect DWG file.
Returns magic string or undef.
ERRORS
detect_dwg_file():
Cannot close file '%s'.
Cannot open file '%s'.EXAMPLE1
use strict;
use warnings;use CAD::AutoCAD::Detect qw(detect_dwg_file);
use File::Temp qw(tempfile);
use IO::Barf qw(barf);
use MIME::Base64;# Data in base64.
my $data = <<'END';
QUMxMDAyAAAAAAAAAAAAAAAK
END# Temp file.
my (undef, $temp_file) = tempfile();# Save data to file.
barf($temp_file, decode_base64($data));# Check file.
my $dwg_magic = detect_dwg_file($temp_file);# Print out.
if ($dwg_magic) {
print "File '$temp_file' is DWG file.\n";
} else {
print "File '$temp_file' isn't DWG file.\n";
}# Output like:
# File '%s' is DWG file.EXAMPLE2
use strict;
use warnings;use CAD::AutoCAD::Detect qw(detect_dwg_file);
# Arguments.
if (@ARGV < 1) {
print STDERR "Usage: $0 file\n";
exit 1;
}
my $file = $ARGV[0];# Check DWG file.
my $dwg_magic = detect_dwg_file($file);# Print out.
if ($dwg_magic) {
print "File '$file' is DWG file.\n";
} else {
print "File '$file' isn't DWG file.\n";
}# Output:
# Usage: detect-dwg-file fileDEPENDENCIES
CAD::AutoCAD::Version, Error::Pure, Exporter, List::Util, Readonly.REPOSITORY
AUTHOR
Michal Josef Špaček
LICENSE AND COPYRIGHT
© 2020-2024 Michal Josef ŠpačekBSD 2-Clause License
VERSION
0.05