Browse code

Fix path issue with build.rs

Olivier Lecointre authored on 02/10/2024 00:17:52
Showing 1 changed files
... ...
@@ -30,9 +30,8 @@ fn get_target_path() -> PathBuf {
30 30
 }
31 31
 
32 32
 fn main() {
33
-	//let _out_dir = env::var("OUT_DIR").unwrap();
34 33
 	let target_dir = get_target_path();
35
-    let src = "/home/olivier/vdocs/Projects/rust/rustapp/emoticon.png";//Path::join(&env::current_dir().unwrap(), "/emoticon.png");
34
+    let src = Path::join(&env::current_dir().unwrap(), "emoticon.png");
36 35
     println!("Source {:?}",src);
37 36
     let dest = Path::join(Path::new(&target_dir), Path::new("emoticon.png"));
38 37
     println!("Dest {:?}",dest);
Browse code

Application code

Olivier Lecointre authored on 02/10/2024 00:05:42
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,40 @@
1
+/*
2
+ * build.rs
3
+ * 
4
+ * Copyright 2018-2024 Olivier Lecointre <olivier[at]cadexis[dot]com>
5
+ * 
6
+ * This program is free software; you can redistribute it and/or modify
7
+ * it under the terms of the GNU General Public License as published by
8
+ * the Free Software Foundation; either version 3 of the License, or
9
+ * (at your option) any later version.
10
+ * 
11
+ * This program is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
+ * GNU General Public License for more details.
15
+ * 
16
+ * You should have received a copy of the GNU General Public License
17
+ * along with this program; if not see <http://www.gnu.org/licenses/>.
18
+ * 
19
+ */
20
+
21
+use std::env;
22
+use std::fs;
23
+use std::path::Path;
24
+use std::path::PathBuf;
25
+
26
+fn get_target_path() -> PathBuf {
27
+    let _out_dir = env::var("OUT_DIR").unwrap();
28
+    let _path = Path::new(&_out_dir).join("../../../");
29
+    return PathBuf::from(_path);
30
+}
31
+
32
+fn main() {
33
+	//let _out_dir = env::var("OUT_DIR").unwrap();
34
+	let target_dir = get_target_path();
35
+    let src = "/home/olivier/vdocs/Projects/rust/rustapp/emoticon.png";//Path::join(&env::current_dir().unwrap(), "/emoticon.png");
36
+    println!("Source {:?}",src);
37
+    let dest = Path::join(Path::new(&target_dir), Path::new("emoticon.png"));
38
+    println!("Dest {:?}",dest);
39
+    fs::copy(src, dest).unwrap();
40
+}