Skip to content

Commit 9cea53b

Browse files
committed
Fix asset conflicts
1 parent cba5c88 commit 9cea53b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+100
-50
lines changed

lesson-07/build.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ fn main() {
1616
.join(env::var("PROFILE").unwrap());
1717

1818
copy(
19-
&manifest_dir.join("shaders"),
20-
&executable_path.join("shaders"),
19+
&manifest_dir.join("assets"),
20+
&executable_path.join("assets-07"),
2121
);
2222
}
2323

lesson-07/src/main.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ pub mod render_gl;
55
pub mod resources;
66

77
use resources::Resources;
8+
use std::path::Path;
89

910
fn main() {
10-
let res = Resources::from_exe_path().unwrap();
11+
let res = Resources::from_relative_exe_path(Path::new("assets-07")).unwrap();
1112

1213
let sdl = sdl2::init().unwrap();
1314
let video_subsystem = sdl.video().unwrap();

lesson-07/src/resources.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,22 @@ pub struct Resources {
2121
}
2222

2323
impl Resources {
24-
pub fn from_exe_path() -> Result<Resources, Error> {
24+
pub fn from_relative_exe_path(rel_path: &Path) -> Result<Resources, Error> {
2525
let exe_file_name = ::std::env::current_exe()
2626
.map_err(|_| Error::FailedToGetExePath)?;
2727

2828
let exe_path = exe_file_name.parent()
2929
.ok_or(Error::FailedToGetExePath)?;
3030

3131
Ok(Resources {
32-
root_path: PathBuf::from(exe_path)
32+
root_path: exe_path.join(rel_path)
3333
})
3434
}
3535

36+
pub fn from_exe_path() -> Result<Resources, Error> {
37+
Resources::from_relative_exe_path(Path::new(""))
38+
}
39+
3640
pub fn load_cstring(&self, resource_name: &str) -> Result<ffi::CString, Error> {
3741
let mut file = fs::File::open(
3842
resource_name_to_path(&self.root_path,resource_name)

lesson-08/build.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ fn main() {
1616
.join(env::var("PROFILE").unwrap());
1717

1818
copy(
19-
&manifest_dir.join("shaders"),
20-
&executable_path.join("shaders"),
19+
&manifest_dir.join("assets"),
20+
&executable_path.join("assets-08"),
2121
);
2222
}
2323

lesson-08/src/main.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ pub mod resources;
77

88
use failure::err_msg;
99
use resources::Resources;
10+
use std::path::Path;
1011

1112
fn main() {
1213
if let Err(e) = run() {
@@ -15,7 +16,7 @@ fn main() {
1516
}
1617

1718
fn run() -> Result<(), failure::Error> {
18-
let res = Resources::from_exe_path()?;
19+
let res = Resources::from_relative_exe_path(Path::new("assets-08")).unwrap();
1920

2021
let sdl = sdl2::init().map_err(err_msg)?;
2122
let video_subsystem = sdl.video().map_err(err_msg)?;

lesson-08/src/resources.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,22 @@ pub struct Resources {
2424
}
2525

2626
impl Resources {
27-
pub fn from_exe_path() -> Result<Resources, Error> {
27+
pub fn from_relative_exe_path(rel_path: &Path) -> Result<Resources, Error> {
2828
let exe_file_name = ::std::env::current_exe()
2929
.map_err(|_| Error::FailedToGetExePath)?;
3030

3131
let exe_path = exe_file_name.parent()
3232
.ok_or(Error::FailedToGetExePath)?;
3333

3434
Ok(Resources {
35-
root_path: PathBuf::from(exe_path)
35+
root_path: exe_path.join(rel_path)
3636
})
3737
}
3838

39+
pub fn from_exe_path() -> Result<Resources, Error> {
40+
Resources::from_relative_exe_path(Path::new(""))
41+
}
42+
3943
pub fn load_cstring(&self, resource_name: &str) -> Result<ffi::CString, Error> {
4044
let mut file = fs::File::open(
4145
resource_name_to_path(&self.root_path,resource_name)

lesson-09/build.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ fn main() {
1616
.join(env::var("PROFILE").unwrap());
1717

1818
copy(
19-
&manifest_dir.join("shaders"),
20-
&executable_path.join("shaders"),
19+
&manifest_dir.join("assets"),
20+
&executable_path.join("assets-09"),
2121
);
2222
}
2323

lesson-09/src/main.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ pub mod resources;
88
use render_gl::data;
99
use failure::err_msg;
1010
use resources::Resources;
11+
use std::path::Path;
1112

1213
#[derive(Copy, Clone, Debug)]
1314
#[repr(C, packed)]
@@ -43,7 +44,7 @@ fn main() {
4344
}
4445

4546
fn run() -> Result<(), failure::Error> {
46-
let res = Resources::from_exe_path()?;
47+
let res = Resources::from_relative_exe_path(Path::new("assets-09")).unwrap();
4748

4849
let sdl = sdl2::init().map_err(err_msg)?;
4950
let video_subsystem = sdl.video().map_err(err_msg)?;

lesson-09/src/resources.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,22 @@ pub struct Resources {
2424
}
2525

2626
impl Resources {
27-
pub fn from_exe_path() -> Result<Resources, Error> {
27+
pub fn from_relative_exe_path(rel_path: &Path) -> Result<Resources, Error> {
2828
let exe_file_name = ::std::env::current_exe()
2929
.map_err(|_| Error::FailedToGetExePath)?;
3030

3131
let exe_path = exe_file_name.parent()
3232
.ok_or(Error::FailedToGetExePath)?;
3333

3434
Ok(Resources {
35-
root_path: PathBuf::from(exe_path)
35+
root_path: exe_path.join(rel_path)
3636
})
3737
}
3838

39+
pub fn from_exe_path() -> Result<Resources, Error> {
40+
Resources::from_relative_exe_path(Path::new(""))
41+
}
42+
3943
pub fn load_cstring(&self, resource_name: &str) -> Result<ffi::CString, Error> {
4044
let mut file = fs::File::open(
4145
resource_name_to_path(&self.root_path,resource_name)

lesson-10/build.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ fn main() {
1616
.join(env::var("PROFILE").unwrap());
1717

1818
copy(
19-
&manifest_dir.join("shaders"),
20-
&executable_path.join("shaders"),
19+
&manifest_dir.join("assets"),
20+
&executable_path.join("assets-10"),
2121
);
2222
}
2323

lesson-10/src/main.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ pub mod resources;
99
use render_gl::data;
1010
use failure::err_msg;
1111
use resources::Resources;
12+
use std::path::Path;
1213

1314
#[derive(VertexAttribPointers)]
1415
#[derive(Copy, Clone, Debug)]
@@ -27,7 +28,7 @@ fn main() {
2728
}
2829

2930
fn run() -> Result<(), failure::Error> {
30-
let res = Resources::from_exe_path()?;
31+
let res = Resources::from_relative_exe_path(Path::new("assets-10")).unwrap();
3132

3233
let sdl = sdl2::init().map_err(err_msg)?;
3334
let video_subsystem = sdl.video().map_err(err_msg)?;

lesson-10/src/resources.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,22 @@ pub struct Resources {
2424
}
2525

2626
impl Resources {
27-
pub fn from_exe_path() -> Result<Resources, Error> {
27+
pub fn from_relative_exe_path(rel_path: &Path) -> Result<Resources, Error> {
2828
let exe_file_name = ::std::env::current_exe()
2929
.map_err(|_| Error::FailedToGetExePath)?;
3030

3131
let exe_path = exe_file_name.parent()
3232
.ok_or(Error::FailedToGetExePath)?;
3333

3434
Ok(Resources {
35-
root_path: PathBuf::from(exe_path)
35+
root_path: exe_path.join(rel_path)
3636
})
3737
}
3838

39+
pub fn from_exe_path() -> Result<Resources, Error> {
40+
Resources::from_relative_exe_path(Path::new(""))
41+
}
42+
3943
pub fn load_cstring(&self, resource_name: &str) -> Result<ffi::CString, Error> {
4044
let mut file = fs::File::open(
4145
resource_name_to_path(&self.root_path,resource_name)

lesson-11/build.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ fn main() {
1616
.join(env::var("PROFILE").unwrap());
1717

1818
copy(
19-
&manifest_dir.join("shaders"),
20-
&executable_path.join("shaders"),
19+
&manifest_dir.join("assets"),
20+
&executable_path.join("assets-11"),
2121
);
2222
}
2323

lesson-11/src/main.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ pub mod resources;
1111
use render_gl::data;
1212
use failure::err_msg;
1313
use resources::Resources;
14+
use std::path::Path;
1415

1516
#[derive(VertexAttribPointers)]
1617
#[derive(Copy, Clone, Debug)]
@@ -29,7 +30,7 @@ fn main() {
2930
}
3031

3132
fn run() -> Result<(), failure::Error> {
32-
let res = Resources::from_exe_path()?;
33+
let res = Resources::from_relative_exe_path(Path::new("assets-11")).unwrap();
3334

3435
let sdl = sdl2::init().map_err(err_msg)?;
3536
let video_subsystem = sdl.video().map_err(err_msg)?;

lesson-11/src/resources.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,22 @@ pub struct Resources {
2424
}
2525

2626
impl Resources {
27-
pub fn from_exe_path() -> Result<Resources, Error> {
27+
pub fn from_relative_exe_path(rel_path: &Path) -> Result<Resources, Error> {
2828
let exe_file_name = ::std::env::current_exe()
2929
.map_err(|_| Error::FailedToGetExePath)?;
3030

3131
let exe_path = exe_file_name.parent()
3232
.ok_or(Error::FailedToGetExePath)?;
3333

3434
Ok(Resources {
35-
root_path: PathBuf::from(exe_path)
35+
root_path: exe_path.join(rel_path)
3636
})
3737
}
3838

39+
pub fn from_exe_path() -> Result<Resources, Error> {
40+
Resources::from_relative_exe_path(Path::new(""))
41+
}
42+
3943
pub fn load_cstring(&self, resource_name: &str) -> Result<ffi::CString, Error> {
4044
let mut file = fs::File::open(
4145
resource_name_to_path(&self.root_path,resource_name)

lesson-12/build.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ fn main() {
1616
.join(env::var("PROFILE").unwrap());
1717

1818
copy(
19-
&manifest_dir.join("shaders"),
20-
&executable_path.join("shaders"),
19+
&manifest_dir.join("assets"),
20+
&executable_path.join("assets-12"),
2121
);
2222
}
2323

lesson-12/src/main.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use render_gl::data;
1212
use render_gl::buffer;
1313
use failure::err_msg;
1414
use resources::Resources;
15+
use std::path::Path;
1516

1617
#[derive(VertexAttribPointers)]
1718
#[derive(Copy, Clone, Debug)]
@@ -30,7 +31,7 @@ fn main() {
3031
}
3132

3233
fn run() -> Result<(), failure::Error> {
33-
let res = Resources::from_exe_path()?;
34+
let res = Resources::from_relative_exe_path(Path::new("assets-12")).unwrap();
3435

3536
let sdl = sdl2::init().map_err(err_msg)?;
3637
let video_subsystem = sdl.video().map_err(err_msg)?;

lesson-12/src/resources.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,22 @@ pub struct Resources {
2424
}
2525

2626
impl Resources {
27-
pub fn from_exe_path() -> Result<Resources, Error> {
27+
pub fn from_relative_exe_path(rel_path: &Path) -> Result<Resources, Error> {
2828
let exe_file_name = ::std::env::current_exe()
2929
.map_err(|_| Error::FailedToGetExePath)?;
3030

3131
let exe_path = exe_file_name.parent()
3232
.ok_or(Error::FailedToGetExePath)?;
3333

3434
Ok(Resources {
35-
root_path: PathBuf::from(exe_path)
35+
root_path: exe_path.join(rel_path)
3636
})
3737
}
3838

39+
pub fn from_exe_path() -> Result<Resources, Error> {
40+
Resources::from_relative_exe_path(Path::new(""))
41+
}
42+
3943
pub fn load_cstring(&self, resource_name: &str) -> Result<ffi::CString, Error> {
4044
let mut file = fs::File::open(
4145
resource_name_to_path(&self.root_path,resource_name)

lesson-13/build.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ fn main() {
1616
.join(env::var("PROFILE").unwrap());
1717

1818
copy(
19-
&manifest_dir.join("shaders"),
20-
&executable_path.join("shaders"),
19+
&manifest_dir.join("assets"),
20+
&executable_path.join("assets-13"),
2121
);
2222
}
2323

lesson-13/src/main.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ mod debug;
1313

1414
use failure::err_msg;
1515
use resources::Resources;
16+
use std::path::Path;
1617
use nalgebra as na;
1718

1819
fn main() {
@@ -22,7 +23,7 @@ fn main() {
2223
}
2324

2425
fn run() -> Result<(), failure::Error> {
25-
let res = Resources::from_exe_path()?;
26+
let res = Resources::from_relative_exe_path(Path::new("assets-13")).unwrap();
2627

2728
let sdl = sdl2::init().map_err(err_msg)?;
2829
let video_subsystem = sdl.video().map_err(err_msg)?;

lesson-13/src/resources.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,22 @@ pub struct Resources {
2424
}
2525

2626
impl Resources {
27-
pub fn from_exe_path() -> Result<Resources, Error> {
27+
pub fn from_relative_exe_path(rel_path: &Path) -> Result<Resources, Error> {
2828
let exe_file_name = ::std::env::current_exe()
2929
.map_err(|_| Error::FailedToGetExePath)?;
3030

3131
let exe_path = exe_file_name.parent()
3232
.ok_or(Error::FailedToGetExePath)?;
3333

3434
Ok(Resources {
35-
root_path: PathBuf::from(exe_path)
35+
root_path: exe_path.join(rel_path)
3636
})
3737
}
3838

39+
pub fn from_exe_path() -> Result<Resources, Error> {
40+
Resources::from_relative_exe_path(Path::new(""))
41+
}
42+
3943
pub fn load_cstring(&self, resource_name: &str) -> Result<ffi::CString, Error> {
4044
let mut file = fs::File::open(
4145
resource_name_to_path(&self.root_path,resource_name)

lesson-14-x/build.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ fn main() {
1616
.join(env::var("PROFILE").unwrap());
1717

1818
copy(
19-
&manifest_dir.join("shaders"),
20-
&executable_path.join("shaders"),
19+
&manifest_dir.join("assets"),
20+
&executable_path.join("assets-14-x"),
2121
);
2222
}
2323

lesson-14-x/src/main.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ mod debug;
1212

1313
use failure::err_msg;
1414
use resources::Resources;
15+
use std::path::Path;
1516
use nalgebra as na;
1617

1718
fn main() {
@@ -21,7 +22,7 @@ fn main() {
2122
}
2223

2324
fn run() -> Result<(), failure::Error> {
24-
let res = Resources::from_exe_path()?;
25+
let res = Resources::from_relative_exe_path(Path::new("assets-14-x")).unwrap();
2526

2627
let sdl = sdl2::init().map_err(err_msg)?;
2728
let video_subsystem = sdl.video().map_err(err_msg)?;

0 commit comments

Comments
 (0)