Skip to content

Commit

Permalink
wasm: Fix operation not supported on std::fs. Closes #115 (#166)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
iceiix authored May 29, 2019
1 parent 3eee3e9 commit 836ab9f
Show file tree
Hide file tree
Showing 12 changed files with 394 additions and 8 deletions.
88 changes: 88 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,7 @@ version = "0"
[dependencies.steven_shared]
path = "./shared"
version = "0"

[dependencies.std_or_web]
path = "./std_or_web"
version = "0"
2 changes: 1 addition & 1 deletion src/console/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use std::collections::HashMap;
use std::any::Any;
use std::cell::{RefCell, Ref};
use std::sync::{Arc, Mutex};
use std::fs;
use std_or_web::fs;
use std::io::{BufWriter, Write, BufRead, BufReader};
use log;

Expand Down
3 changes: 2 additions & 1 deletion src/protocol/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use aes::Aes128;
use cfb8::Cfb8;
use cfb8::stream_cipher::{NewStreamCipher, StreamCipher};
use serde_json;
use std_or_web::fs;
#[cfg(not(target_arch = "wasm32"))]
use reqwest;

Expand Down Expand Up @@ -1070,7 +1071,7 @@ impl Conn {

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

let packet = packet::packet_by_id(self.protocol_version, self.state, dir, id, &mut buf)?;
Expand Down
2 changes: 1 addition & 1 deletion src/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,7 @@ impl TextureManager {
#[cfg(not(target_arch = "wasm32"))]
fn obtain_skin(client: &::reqwest::Client, hash: &str) -> Result<image::DynamicImage, ::std::io::Error> {
use std::io::Read;
use std::fs;
use std_or_web::fs;
use std::path::Path;
use std::io::{Error, ErrorKind};
let path = format!("skin-cache/{}/{}.png", &hash[..2], hash);
Expand Down
2 changes: 1 addition & 1 deletion src/resources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ extern crate steven_resources as internal;
use std::thread;
use std::path;
use std::io;
use std::fs;
use std_or_web::fs;
use std::sync::mpsc;
use std::sync::{Arc, Mutex};
use std::collections::HashMap;
Expand Down
2 changes: 1 addition & 1 deletion src/screen/edit_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use std::fs;
use std_or_web::fs;
use std::collections::BTreeMap;

use crate::ui;
Expand Down
2 changes: 1 addition & 1 deletion src/screen/server_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use std::fs;
use std_or_web::fs;
use std::thread;
use std::sync::mpsc;
use std::rc::Rc;
Expand Down
Loading

0 comments on commit 836ab9f

Please sign in to comment.