-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
m1sk9
committed
Jul 27, 2023
1 parent
a4809b2
commit 6e8121a
Showing
4 changed files
with
22 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
/target | ||
.env | ||
|
||
# 一時的なテキストファイルの生成に使用する | ||
/temp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,19 @@ | ||
use std::fs::File; | ||
use std::fs::{create_dir, File}; | ||
use std::io::Write; | ||
|
||
pub fn create_temp_file(content: String) -> File { | ||
let mut temp_file = File::create("temp.txt").expect("一時ファイルの作成に失敗しました。"); | ||
temp_file | ||
.write_all(content.as_ref()) | ||
.expect("一時ファイルへの書き込みに失敗しました。"); | ||
return temp_file; | ||
pub fn create_temp_file(content: String) { | ||
match create_dir("temp") { | ||
Ok(_) => { | ||
println!("一時フォルダを作成しました。"); | ||
|
||
let mut temp_file = | ||
File::create("temp/temp.txt").expect("一時ファイルの作成に失敗しました。"); | ||
temp_file | ||
.write_all(content.as_ref()) | ||
.expect("一時ファイルへの書き込みに失敗しました。"); | ||
|
||
println!("一時ファイルを作成しました。") | ||
} | ||
Err(_) => panic!("一時ディレクトリを作成できませんでした。"), | ||
} | ||
} |