about summary refs log tree commit diff
path: root/pkgs/applications/science/electronics/kicad/writable.patch
blob: a2969f26f43ba85817e46888fa6d7d4078b74d1b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
commit 6a72fd032405515e468797be91b5a6ebcbbb5fd8
Author: Evils <evils.devils@protonmail.com>
Date:   Wed Nov 23 19:49:13 2022 +0100

    ensure new projects are writable

diff --git a/kicad/kicad_manager_frame.cpp b/kicad/kicad_manager_frame.cpp
index 7ee8090858..391514519c 100644
--- a/kicad/kicad_manager_frame.cpp
+++ b/kicad/kicad_manager_frame.cpp
@@ -638,6 +638,12 @@ void KICAD_MANAGER_FRAME::CreateNewProject( const wxFileName& aProjectFileName,
 
                 // wxFFile dtor will close the file
             }
+
+            if( destFileName.IsOk() && !destFileName.IsFileWritable() )
+            {
+                destFileName.SetPermissions(0644);
+            }
+
         }
     }
 
diff --git a/kicad/project_template.cpp b/kicad/project_template.cpp
index bf951fcddb..2bef94326b 100644
--- a/kicad/project_template.cpp
+++ b/kicad/project_template.cpp
@@ -282,6 +282,21 @@ bool PROJECT_TEMPLATE::CreateProject( wxFileName& aNewProjectPath, wxString* aEr
 
             result = false;
         }
+	else if( !destFile.IsFileWritable() && !destFile.SetPermissions(0644) )
+        {
+            if( aErrorMsg )
+            {
+                if( !aErrorMsg->empty() )
+                    *aErrorMsg += "\n";
+
+                wxString msg;
+
+                msg.Printf( _( "Cannot make file writable: '%s'." ), destFile.GetFullPath() );
+                *aErrorMsg += msg;
+            }
+
+            result = false;
+	}
     }
 
     return result;