Skip to content

Commit ae9a4c0

Browse files
committed
Implement reading BtrfsUnlinkCommand
1 parent 8d168a7 commit ae9a4c0

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

btrfs-io/src/main/java/nl/gmta/btrfs/io/BtrfsStreamReader.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import nl.gmta.btrfs.structure.stream.BtrfsTimespec;
1919
import nl.gmta.btrfs.structure.stream.BtrfsTruncateCommand;
2020
import nl.gmta.btrfs.structure.stream.BtrfsUTimesCommand;
21+
import nl.gmta.btrfs.structure.stream.BtrfsUnlinkCommand;
2122
import nl.gmta.btrfs.structure.stream.BtrfsWriteCommand;
2223

2324
public class BtrfsStreamReader implements AutoCloseable {
@@ -109,6 +110,9 @@ private BtrfsStreamCommand readCommand() throws IOException {
109110
case TRUNCATE:
110111
command = this.readTruncateCommand(header);
111112
break;
113+
case UNLINK:
114+
command = this.readUnlinkCommand(header);
115+
break;
112116
case UTIMES:
113117
command = this.readUTimesCommand(header);
114118
break;
@@ -185,6 +189,12 @@ private BtrfsTruncateCommand readTruncateCommand(BtrfsStreamCommandHeader header
185189
return new BtrfsTruncateCommand(header, path, size);
186190
}
187191

192+
private BtrfsUnlinkCommand readUnlinkCommand(BtrfsStreamCommandHeader header) throws IOException {
193+
String path = (String) this.readAttribute(BtrfsAttributeType.PATH);
194+
195+
return new BtrfsUnlinkCommand(header, path);
196+
}
197+
188198
private BtrfsUTimesCommand readUTimesCommand(BtrfsStreamCommandHeader header) throws IOException {
189199
String path = (String) this.readAttribute(BtrfsAttributeType.PATH);
190200
BtrfsTimespec atime = (BtrfsTimespec) this.readAttribute(BtrfsAttributeType.ATIME);
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package nl.gmta.btrfs.structure.stream;
2+
3+
public class BtrfsUnlinkCommand extends BtrfsStreamCommand {
4+
private final String path;
5+
6+
public BtrfsUnlinkCommand(BtrfsStreamCommandHeader header, String path) {
7+
super(header);
8+
9+
this.path = path;
10+
}
11+
12+
public String getPath() {
13+
return this.path;
14+
}
15+
16+
@Override
17+
public String toString() {
18+
return String.format(
19+
"%s{header=%s path='%s'}",
20+
this.getClass().getSimpleName(),
21+
this.header,
22+
this.path
23+
);
24+
}
25+
}

0 commit comments

Comments
 (0)