Skip to content

Commit db827a9

Browse files
committed
perl device,inode
1 parent fd7e655 commit db827a9

File tree

6 files changed

+54
-2
lines changed

6 files changed

+54
-2
lines changed

+stdlib/+perl/device.m

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
function r = device(file)
2+
3+
cwd = fileparts(fullfile(mfilename('fullpath')));
4+
5+
[r, s] = perl(cwd + "/device.pl", file);
6+
if s == 0
7+
r = str2double(r);
8+
else
9+
r = [];
10+
end
11+
12+
r = uint64(r);
13+
14+
end

+stdlib/+perl/device.pl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env perl
2+
use strict;
3+
use warnings;
4+
5+
@ARGV == 1 or die "Usage: $0 <path>\n";
6+
my $path = shift;
7+
8+
my @st = stat($path);
9+
@st ? () : die "stat($path): $!\n";
10+
11+
# Print the device number (element 0 of stat array)
12+
print $st[0];

+stdlib/+perl/inode.m

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
function r = inode(file)
2+
3+
cwd = fileparts(fullfile(mfilename('fullpath')));
4+
5+
[r, s] = perl(cwd + "/inode.pl", file);
6+
if s == 0
7+
r = str2double(r);
8+
else
9+
r = [];
10+
end
11+
12+
r = uint64(r);
13+
14+
end

+stdlib/+perl/inode.pl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env perl
2+
use strict;
3+
use warnings;
4+
5+
@ARGV == 1 or die "Usage: $0 <path>\n";
6+
my $path = shift;
7+
8+
my @st = stat($path);
9+
@st ? () : die "stat($path): $!\n";
10+
11+
# Print the inode number (element 1 of stat array)
12+
print $st[1];

+stdlib/device.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
function [i, b] = device(file, backend)
1010
arguments
1111
file
12-
backend (1,:) string = ["java", "python", "sys"]
12+
backend (1,:) string = ["java", "perl", "python", "sys"]
1313
end
1414

1515
o = stdlib.Backend(mfilename(), backend);

+stdlib/inode.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
function [i, b] = inode(file, backend)
1010
arguments
1111
file string
12-
backend (1,:) string = ["java", "python", "sys"]
12+
backend (1,:) string = ["java", "perl", "python", "sys"]
1313
end
1414

1515
o = stdlib.Backend(mfilename(), backend);

0 commit comments

Comments
 (0)