Skip to content

Commit 836ab9f

Browse files
authored
wasm: Fix operation not supported on std::fs. Closes #115 (#166)
* Add new web-based std::fs replacement, localstoragefs: https://github.com/iceiix/localstoragefs * Add std_or_web to switch between std::fs (native) or localstoragefs (web) * Update www readme for new missing glutin/winit links, opens issue #171
1 parent 3eee3e9 commit 836ab9f

File tree

12 files changed

+394
-8
lines changed

12 files changed

+394
-8
lines changed

Cargo.lock

+88
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,7 @@ version = "0"
6666
[dependencies.steven_shared]
6767
path = "./shared"
6868
version = "0"
69+
70+
[dependencies.std_or_web]
71+
path = "./std_or_web"
72+
version = "0"

src/console/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use std::collections::HashMap;
1717
use std::any::Any;
1818
use std::cell::{RefCell, Ref};
1919
use std::sync::{Arc, Mutex};
20-
use std::fs;
20+
use std_or_web::fs;
2121
use std::io::{BufWriter, Write, BufRead, BufReader};
2222
use log;
2323

src/protocol/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use aes::Aes128;
1919
use cfb8::Cfb8;
2020
use cfb8::stream_cipher::{NewStreamCipher, StreamCipher};
2121
use serde_json;
22+
use std_or_web::fs;
2223
#[cfg(not(target_arch = "wasm32"))]
2324
use reqwest;
2425

@@ -1070,7 +1071,7 @@ impl Conn {
10701071

10711072
if network_debug {
10721073
debug!("about to parse id={:x}, dir={:?} state={:?}", id, dir, self.state);
1073-
std::fs::File::create("last-packet")?.write_all(buf.get_ref())?;
1074+
fs::File::create("last-packet")?.write_all(buf.get_ref())?;
10741075
}
10751076

10761077
let packet = packet::packet_by_id(self.protocol_version, self.state, dir, id, &mut buf)?;

src/render/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,7 @@ impl TextureManager {
865865
#[cfg(not(target_arch = "wasm32"))]
866866
fn obtain_skin(client: &::reqwest::Client, hash: &str) -> Result<image::DynamicImage, ::std::io::Error> {
867867
use std::io::Read;
868-
use std::fs;
868+
use std_or_web::fs;
869869
use std::path::Path;
870870
use std::io::{Error, ErrorKind};
871871
let path = format!("skin-cache/{}/{}.png", &hash[..2], hash);

src/resources.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ extern crate steven_resources as internal;
1717
use std::thread;
1818
use std::path;
1919
use std::io;
20-
use std::fs;
20+
use std_or_web::fs;
2121
use std::sync::mpsc;
2222
use std::sync::{Arc, Mutex};
2323
use std::collections::HashMap;

src/screen/edit_server.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
use std::fs;
15+
use std_or_web::fs;
1616
use std::collections::BTreeMap;
1717

1818
use crate::ui;

src/screen/server_list.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
use std::fs;
15+
use std_or_web::fs;
1616
use std::thread;
1717
use std::sync::mpsc;
1818
use std::rc::Rc;

0 commit comments

Comments
 (0)