Fix paths being created with trailing "/" always
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
fbd79b5b41
commit
d2f4c0afe1
41
src/sys.zig
41
src/sys.zig
|
@ -550,26 +550,39 @@ pub const FileSystem = enum {
|
||||||
.length = 0,
|
.length = 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
for (sequences) |sequence| if (sequence.len != 0) {
|
if (sequences.len != 0) {
|
||||||
var components = mem.Spliterator(u8){
|
const last_sequence_index = sequences.len - 1;
|
||||||
.source = sequence,
|
|
||||||
.delimiter = "/",
|
|
||||||
};
|
|
||||||
|
|
||||||
while (components.next()) |component| if (component.len != 0) {
|
for (sequences) |sequence, index| if (sequence.len != 0) {
|
||||||
for (component) |byte| {
|
var components = mem.Spliterator(u8){
|
||||||
|
.source = sequence,
|
||||||
|
.delimiter = "/",
|
||||||
|
};
|
||||||
|
|
||||||
|
while (components.next()) |component| if (component.len != 0) {
|
||||||
|
for (component) |byte| {
|
||||||
|
if (path.length == Path.max) return error.TooLong;
|
||||||
|
|
||||||
|
path.buffer[path.length] = byte;
|
||||||
|
path.length += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (components.hasNext()) {
|
||||||
|
if (path.length == Path.max) return error.TooLong;
|
||||||
|
|
||||||
|
path.buffer[path.length] = '/';
|
||||||
|
path.length += 1;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (index < last_sequence_index) {
|
||||||
if (path.length == Path.max) return error.TooLong;
|
if (path.length == Path.max) return error.TooLong;
|
||||||
|
|
||||||
path.buffer[path.length] = byte;
|
path.buffer[path.length] = '/';
|
||||||
path.length += 1;
|
path.length += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (path.length == Path.max) return error.TooLong;
|
|
||||||
|
|
||||||
path.buffer[path.length] = '/';
|
|
||||||
path.length += 1;
|
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue