Merge branch 'master' into zig-0.15.0
This commit is contained in:
commit
724dc9200d
2 changed files with 4 additions and 2 deletions
|
@ -1341,6 +1341,8 @@ pub fn store_to_existing_file_const(self: *const Self, file_path: []const u8) St
|
|||
}
|
||||
|
||||
pub fn store_to_new_file_const(self: *const Self, file_path: []const u8) StoreToFileError!void {
|
||||
if (std.fs.path.dirname(file_path)) |dir_name|
|
||||
try cwd().makePath(dir_name);
|
||||
const file = try cwd().createFile(file_path, .{ .read = true, .truncate = true });
|
||||
defer file.close();
|
||||
try self.store_to_file_const(file);
|
||||
|
|
|
@ -30,7 +30,7 @@ pub fn get_all() []const FileType {
|
|||
|
||||
pub fn guess_static(file_path: ?[]const u8, content: []const u8) ?FileType {
|
||||
if (guess_first_line_static(content)) |ft| return ft;
|
||||
for (static_file_types.values()) |*file_type|
|
||||
for (static_file_types.values()) |file_type|
|
||||
if (file_path) |fp| if (match_file_type(file_type.extensions, fp))
|
||||
return file_type;
|
||||
return null;
|
||||
|
@ -38,7 +38,7 @@ pub fn guess_static(file_path: ?[]const u8, content: []const u8) ?FileType {
|
|||
|
||||
fn guess_first_line_static(content: []const u8) ?FileType {
|
||||
const first_line = if (std.mem.indexOf(u8, content, "\n")) |pos| content[0..pos] else content;
|
||||
for (static_file_types) |*file_type|
|
||||
for (static_file_types.values()) |file_type|
|
||||
if (file_type.first_line_matches) |match|
|
||||
if (match_first_line(match.prefix, match.content, first_line))
|
||||
return file_type;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue