mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-24 09:56:51 +00:00
Co-authored-by: theseyan <sayanjyotidasworkmail@gmai.com>
This commit is contained in:
@@ -675,6 +675,7 @@ class file:
|
|||||||
"""
|
"""
|
||||||
path = Path(path)
|
path = Path(path)
|
||||||
path.parent.mkdir(parents=True, exist_ok=True)
|
path.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
if format == None:
|
if format == None:
|
||||||
format = ifcopenshell.guess_format(path)
|
format = ifcopenshell.guess_format(path)
|
||||||
if format == ".ifcXML":
|
if format == ".ifcXML":
|
||||||
@@ -690,8 +691,7 @@ class file:
|
|||||||
if format == ".ifcZIP":
|
if format == ".ifcZIP":
|
||||||
return self.write(path, ".ifc", zipped=True)
|
return self.write(path, ".ifc", zipped=True)
|
||||||
self.wrapped_data.write(str(path))
|
self.wrapped_data.write(str(path))
|
||||||
if not path.exists():
|
|
||||||
raise PermissionError(f"Failed to write to '{path}', check folder permissions.")
|
|
||||||
if zipped:
|
if zipped:
|
||||||
unzipped_path = path.with_suffix(format)
|
unzipped_path = path.with_suffix(format)
|
||||||
path.rename(unzipped_path)
|
path.rename(unzipped_path)
|
||||||
|
|||||||
@@ -142,6 +142,9 @@ static IfcUtil::ArgumentType helper_fn_attribute_type(const IfcUtil::IfcBaseClas
|
|||||||
|
|
||||||
void write(const std::string& fn) {
|
void write(const std::string& fn) {
|
||||||
std::ofstream f(IfcUtil::path::from_utf8(fn).c_str());
|
std::ofstream f(IfcUtil::path::from_utf8(fn).c_str());
|
||||||
|
if (!f.good()) {
|
||||||
|
throw std::runtime_error("Failed to write to path: '" + fn + "', check folder and file permissions.");
|
||||||
|
}
|
||||||
f << (*$self);
|
f << (*$self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user