압축파일 안 파일 열기와 선택 항목 풀기 메뉴 추가
- umask 002로 만든 775 출력 폴더를 개인 그룹이면 허용함 - 부모 창 안 작업 창 닫기 버튼에 마우스 올림 표시를 넣음 - 파일을 더블클릭하면 압축파일 옆 임시 폴더에 풀어 기본 프로그램으로 엶 - 마우스 뒤로 버튼으로 상위 폴더로 이동함 - 오른쪽 클릭 메뉴로 선택 항목을 새 폴더나 고른 폴더에 풂 - 부모 안 작업 창을 끌 때 목록 선택 사각형이 생기지 않게 함 Co-Authored-By: Claude Opus 5.5 <[email protected]>
- 작성자
- LeeJunyoung
- 작성 시각
- 커밋
26121d4cc8943aa4e2335550bd94f35b8a81a777- 부모
- f5399dd
변경된 파일 10개
+909-29| @@ -194,6 +194,50 @@ mod platform { | ||
| 194 | 194 | fn renameat(fd: i32, path: *const i8, newfd: i32, newpath: *const i8) -> i32; |
| 195 | 195 | fn unlinkat(fd: i32, path: *const i8, flags: i32) -> i32; |
| 196 | 196 | fn geteuid() -> u32; |
| 197 | 추가: fn getegid() -> u32; | |
| 198 | 추가: fn getgrgid_r( | |
| 199 | 추가: gid: u32, | |
| 200 | 추가: group: *mut Group, | |
| 201 | 추가: buffer: *mut i8, | |
| 202 | 추가: length: usize, | |
| 203 | 추가: result: *mut *mut Group, | |
| 204 | 추가: ) -> i32; | |
| 205 | 추가: } | |
| 206 | 추가: #[repr(C)] | |
| 207 | 추가: struct Group { | |
| 208 | 추가: name: *mut i8, | |
| 209 | 추가: password: *mut i8, | |
| 210 | 추가: gid: u32, | |
| 211 | 추가: members: *mut *mut i8, | |
| 212 | 추가: } | |
| 213 | 추가: /// 현재 계정의 기본 그룹이 따로 등록된 구성원이 없는 개인 그룹인지 확인함. | |
| 214 | 추가: /// Ubuntu는 계정마다 같은 이름의 개인 그룹을 만들고 umask 002를 써서, | |
| 215 | 추가: /// 파일 관리자나 폴더 선택 창에서 새로 만든 폴더가 그룹 쓰기 권한(775)을 가짐. | |
| 216 | 추가: fn private_group(gid: u32) -> bool { | |
| 217 | 추가: if gid != unsafe { getegid() } { | |
| 218 | 추가: return false; | |
| 219 | 추가: } | |
| 220 | 추가: let mut group = Group { | |
| 221 | 추가: name: std::ptr::null_mut(), | |
| 222 | 추가: password: std::ptr::null_mut(), | |
| 223 | 추가: gid: 0, | |
| 224 | 추가: members: std::ptr::null_mut(), | |
| 225 | 추가: }; | |
| 226 | 추가: let mut result = std::ptr::null_mut(); | |
| 227 | 추가: let mut buffer = vec![0i8; 16 * 1024]; | |
| 228 | 추가: let status = unsafe { | |
| 229 | 추가: getgrgid_r( | |
| 230 | 추가: gid, | |
| 231 | 추가: &mut group, | |
| 232 | 추가: buffer.as_mut_ptr(), | |
| 233 | 추가: buffer.len(), | |
| 234 | 추가: &mut result, | |
| 235 | 추가: ) | |
| 236 | 추가: }; | |
| 237 | 추가: // 그룹 정보를 읽지 못하면 안전하다고 볼 근거가 없으므로 거부함. | |
| 238 | 추가: status == 0 | |
| 239 | 추가: && !result.is_null() | |
| 240 | 추가: && (group.members.is_null() || unsafe { *group.members }.is_null()) | |
| 197 | 241 | } |
| 198 | 242 | pub struct Dir { |
| 199 | 243 | file: File, |
| @@ -242,7 +286,13 @@ mod platform { | ||
| 242 | 286 | fn trusted(&self) -> Result<()> { |
| 243 | 287 | let m = self.file.metadata().map_err(|_| ErrorCode::Io)?; |
| 244 | 288 | // 다른 계정이 바꿀 수 있는 출력 폴더를 거부함. |
| 245 | 삭제: if !m.is_dir() || m.uid() != unsafe { geteuid() } || m.mode() & 0o022 != 0 { | |
| 289 | 추가: // 그룹 쓰기는 그 그룹이 현재 계정만의 개인 그룹일 때만 허용함. | |
| 290 | 추가: let group_writable = m.mode() & 0o020 != 0; | |
| 291 | 추가: if !m.is_dir() | |
| 292 | 추가: || m.uid() != unsafe { geteuid() } | |
| 293 | 추가: || m.mode() & 0o002 != 0 | |
| 294 | 추가: || (group_writable && !private_group(m.gid())) | |
| 295 | 추가: { | |
| 246 | 296 | return Err(ErrorCode::UnsafePath); |
| 247 | 297 | } |
| 248 | 298 | Ok(()) |
| @@ -479,3 +479,125 @@ pub fn excluded_split(path: &Path) -> bool { | ||
| 479 | 479 | .to_ascii_lowercase(); |
| 480 | 480 | name.ends_with(".zip.001") || name.ends_with(".z01") || name.ends_with(".rar") |
| 481 | 481 | } |
| 482 | 추가: | |
| 483 | 추가: /// 같은 이름이 이미 있으면 `이름 (1)`, `이름 (2)`처럼 비어 있는 이름을 찾음. | |
| 484 | 추가: pub fn unique_folder(base: &Path) -> PathBuf { | |
| 485 | 추가: let taken = |path: &Path| fs::symlink_metadata(path).is_ok(); | |
| 486 | 추가: if !taken(base) { | |
| 487 | 추가: return base.to_path_buf(); | |
| 488 | 추가: } | |
| 489 | 추가: let name = base.file_name().unwrap_or_default().to_string_lossy(); | |
| 490 | 추가: (1..) | |
| 491 | 추가: .map(|n| base.with_file_name(format!("{name} ({n})"))) | |
| 492 | 추가: .find(|path| !taken(path)) | |
| 493 | 추가: .unwrap() | |
| 494 | 추가: } | |
| 495 | 추가: | |
| 496 | 추가: fn private_dir(path: &Path) -> io::Result<()> { | |
| 497 | 추가: let mut builder = fs::DirBuilder::new(); | |
| 498 | 추가: #[cfg(unix)] | |
| 499 | 추가: { | |
| 500 | 추가: use std::os::unix::fs::DirBuilderExt; | |
| 501 | 추가: builder.mode(0o700); | |
| 502 | 추가: } | |
| 503 | 추가: builder.create(path) | |
| 504 | 추가: } | |
| 505 | 추가: | |
| 506 | 추가: /// 압축파일 안 파일을 기본 프로그램으로 열 때 쓸 임시 폴더를 만듦. | |
| 507 | 추가: /// 압축파일과 같은 폴더에 만들고, 그곳에 만들 수 없으면 시스템 임시 폴더를 씀. | |
| 508 | 추가: /// 숨김 폴더로 만들지 않음. snap으로 설치한 Firefox 등은 홈 바로 아래 숨김 폴더와 | |
| 509 | 추가: /// 시스템 임시 폴더의 파일을 읽지 못해 열기 요청을 조용히 무시함. | |
| 510 | 추가: pub fn create_open_root(archive: &Path) -> io::Result<PathBuf> { | |
| 511 | 추가: let name = archive.file_name().unwrap_or_default().to_string_lossy(); | |
| 512 | 추가: let mut error = None; | |
| 513 | 추가: if let Some(parent) = archive.parent().filter(|p| !p.as_os_str().is_empty()) { | |
| 514 | 추가: let base = parent.join(open_root_name(&name)); | |
| 515 | 추가: for _ in 0..8 { | |
| 516 | 추가: let path = unique_folder(&base); | |
| 517 | 추가: match private_dir(&path) { | |
| 518 | 추가: Ok(()) => return Ok(path), | |
| 519 | 추가: Err(e) if e.kind() == io::ErrorKind::AlreadyExists => continue, | |
| 520 | 추가: Err(e) => { | |
| 521 | 추가: error = Some(e); | |
| 522 | 추가: break; | |
| 523 | 추가: } | |
| 524 | 추가: } | |
| 525 | 추가: } | |
| 526 | 추가: } | |
| 527 | 추가: let base = std::env::temp_dir().join(format!("zipelo-{}-{name}", std::process::id())); | |
| 528 | 추가: let path = unique_folder(&base); | |
| 529 | 추가: private_dir(&path).map_err(|e| error.unwrap_or(e))?; | |
| 530 | 추가: Ok(path) | |
| 531 | 추가: } | |
| 532 | 추가: | |
| 533 | 추가: /// 열기용 임시 폴더 이름. 예: `자료.zip (Zipelo 임시)`. | |
| 534 | 추가: pub fn open_root_name(archive_name: &str) -> String { | |
| 535 | 추가: format!("{archive_name} (Zipelo 임시)") | |
| 536 | 추가: } | |
| 537 | 추가: | |
| 538 | 추가: /// 이 앱이 만든 열기용 폴더를 지움. 다른 프로그램이 파일을 쓰고 있으면 남을 수 있음. | |
| 539 | 추가: pub fn remove_open_root(path: &Path) { | |
| 540 | 추가: let _ = fs::remove_dir_all(path); | |
| 541 | 추가: } | |
| 542 | 추가: | |
| 543 | 추가: /// 기본 프로그램으로 열면 실행될 수 있는 파일은 바로 열지 않음. | |
| 544 | 추가: /// Windows는 스크립트도 연결 프로그램이 바로 실행하므로 범위가 넓고, | |
| 545 | 추가: /// Linux는 스크립트를 편집기로 열므로 실행·설치 파일만 막음. | |
| 546 | 추가: pub fn blocked_open(name: &str) -> bool { | |
| 547 | 추가: #[cfg(windows)] | |
| 548 | 추가: const EXECUTABLE: &[&str] = &[ | |
| 549 | 추가: "exe", "com", "bat", "cmd", "scr", "pif", "msi", "msp", "msc", "ps1", "psm1", "vbs", | |
| 550 | 추가: "vbe", "js", "jse", "wsf", "wsh", "hta", "cpl", "lnk", "url", "reg", "jar", "inf", "scf", | |
| 551 | 추가: "chm", "dll", "sys", "appref-ms", "application", "gadget", "settingcontent-ms", | |
| 552 | 추가: ]; | |
| 553 | 추가: #[cfg(not(windows))] | |
| 554 | 추가: const EXECUTABLE: &[&str] = &[ | |
| 555 | 추가: "desktop", "appimage", "run", "bin", "jar", "deb", "rpm", "snap", "flatpakref", | |
| 556 | 추가: "flatpak", "exe", "msi", | |
| 557 | 추가: ]; | |
| 558 | 추가: open_extension(name).is_some_and(|ext| EXECUTABLE.contains(&ext.to_ascii_lowercase().as_str())) | |
| 559 | 추가: } | |
| 560 | 추가: | |
| 561 | 추가: fn open_extension(name: &str) -> Option<&str> { | |
| 562 | 추가: let leaf = name.rsplit(['/', '\\']).next().unwrap_or(name); | |
| 563 | 추가: leaf.rsplit_once('.') | |
| 564 | 추가: .map(|(_, ext)| ext) | |
| 565 | 추가: .filter(|ext| !ext.is_empty()) | |
| 566 | 추가: } | |
| 567 | 추가: | |
| 568 | 추가: /// 실행 파일이라 열지 않았다는 짧은 안내. 압축은 풀지 않음. | |
| 569 | 추가: pub fn open_blocked_text(name: &str) -> String { | |
| 570 | 추가: match open_extension(name) { | |
| 571 | 추가: Some(ext) => format!("실행 파일(.{ext})은 안전을 위해 바로 열 수 없습니다"), | |
| 572 | 추가: None => "실행 파일은 안전을 위해 바로 열 수 없습니다".into(), | |
| 573 | 추가: } | |
| 574 | 추가: } | |
| 575 | 추가: | |
| 576 | 추가: pub const OPEN_FAILED: &str = "파일을 열 프로그램을 실행하지 못했습니다"; | |
| 577 | 추가: pub const OPEN_MISSING: &str = "풀린 파일을 찾지 못해 열지 못했습니다"; | |
| 578 | 추가: | |
| 579 | 추가: /// 운영체제에 설정된 기본 프로그램으로 파일을 엶. | |
| 580 | 추가: pub fn open_with_default(path: &Path) -> Result<(), String> { | |
| 581 | 추가: #[cfg(windows)] | |
| 582 | 추가: let mut command = { | |
| 583 | 추가: let mut command = std::process::Command::new("explorer.exe"); | |
| 584 | 추가: command.arg(path); | |
| 585 | 추가: command | |
| 586 | 추가: }; | |
| 587 | 추가: #[cfg(not(windows))] | |
| 588 | 추가: let mut command = { | |
| 589 | 추가: let mut command = std::process::Command::new("xdg-open"); | |
| 590 | 추가: command.arg(path); | |
| 591 | 추가: command | |
| 592 | 추가: }; | |
| 593 | 추가: command | |
| 594 | 추가: .stdin(std::process::Stdio::null()) | |
| 595 | 추가: .stdout(std::process::Stdio::null()) | |
| 596 | 추가: .stderr(std::process::Stdio::null()); | |
| 597 | 추가: let mut child = command.spawn().map_err(|_| OPEN_FAILED.to_owned())?; | |
| 598 | 추가: // 끝난 자식 프로세스를 거둬 좀비로 남지 않게 함. | |
| 599 | 추가: std::thread::spawn(move || { | |
| 600 | 추가: let _ = child.wait(); | |
| 601 | 추가: }); | |
| 602 | 추가: Ok(()) | |
| 603 | 추가: } |
| @@ -198,6 +198,24 @@ struct Marquee { | ||
| 198 | 198 | /// 파일 목록 한 행의 높이. 행 안의 크기 칸(theme::ROW)이 위아래 2px 여백으로 들어감. |
| 199 | 199 | const LIST_ROW: f32 = 36.0; |
| 200 | 200 | |
| 201 | 추가: /// 기본 프로그램으로 열려고 임시 폴더에 푸는 작업. 끝나면 원래 풀 위치로 되돌림. | |
| 202 | 추가: struct OpenRequest { | |
| 203 | 추가: folder: PathBuf, | |
| 204 | 추가: /// 풀린 뒤 열 파일의 압축파일 안 경로. 작업자는 새로 만든 상위 폴더도 출력으로 알리므로 | |
| 205 | 추가: /// 출력 목록에서 이 경로와 같은 항목을 찾아 엶. | |
| 206 | 추가: name: String, | |
| 207 | 추가: destination: PathBuf, | |
| 208 | 추가: automatic: bool, | |
| 209 | 추가: } | |
| 210 | 추가: | |
| 211 | 추가: /// 파일 목록의 오른쪽 클릭 메뉴에서 고른 동작. | |
| 212 | 추가: enum MenuAction { | |
| 213 | 추가: NewFolder, | |
| 214 | 추가: ChooseFolder, | |
| 215 | 추가: } | |
| 216 | 추가: | |
| 217 | 추가: type Opener = Box<dyn FnMut(&Path) -> Result<(), String>>; | |
| 218 | 추가: | |
| 201 | 219 | pub struct ArchiveApp { |
| 202 | 220 | pub model: Model, |
| 203 | 221 | factory: Box<dyn Factory>, |
| @@ -262,6 +280,13 @@ pub struct ArchiveApp { | ||
| 262 | 280 | checked_destination: bool, |
| 263 | 281 | ui_error: Option<String>, |
| 264 | 282 | initialized: bool, |
| 283 | 추가: opening: Option<OpenRequest>, | |
| 284 | 추가: /// 마지막 풀기가 기본 프로그램으로 열기였으면 그 항목. 다시 시도할 때 다시 엶. | |
| 285 | 추가: last_open: Option<u32>, | |
| 286 | 추가: /// 압축파일별 열기용 임시 폴더. 앱을 닫을 때 지움. | |
| 287 | 추가: open_roots: Vec<(PathBuf, PathBuf)>, | |
| 288 | 추가: open_count: u64, | |
| 289 | 추가: opener: Opener, | |
| 265 | 290 | #[cfg(all(feature = "ui-fixture", debug_assertions))] |
| 266 | 291 | scenario_marquee: Option<egui::Rect>, |
| 267 | 292 | #[cfg(all(feature = "ui-fixture", debug_assertions))] |
| @@ -329,6 +354,11 @@ impl ArchiveApp { | ||
| 329 | 354 | checked_destination: false, |
| 330 | 355 | ui_error: None, |
| 331 | 356 | initialized: false, |
| 357 | 추가: opening: None, | |
| 358 | 추가: last_open: None, | |
| 359 | 추가: open_roots: Vec::new(), | |
| 360 | 추가: open_count: 0, | |
| 361 | 추가: opener: Box::new(present::open_with_default), | |
| 332 | 362 | #[cfg(all(feature = "ui-fixture", debug_assertions))] |
| 333 | 363 | scenario_marquee: None, |
| 334 | 364 | #[cfg(all(feature = "ui-fixture", debug_assertions))] |
| @@ -344,6 +374,116 @@ impl ArchiveApp { | ||
| 344 | 374 | self.dialogs = dialogs; |
| 345 | 375 | } |
| 346 | 376 | |
| 377 | 추가: /// 파일을 기본 프로그램으로 여는 방법을 바꿈. 시험에서 실제 프로그램 실행을 막을 때 씀. | |
| 378 | 추가: pub fn set_opener(&mut self, opener: Opener) { | |
| 379 | 추가: self.opener = opener; | |
| 380 | 추가: } | |
| 381 | 추가: | |
| 382 | 추가: /// 압축파일 안 파일 하나를 임시 폴더에 풀고 기본 프로그램으로 엶. | |
| 383 | 추가: pub fn open_entry(&mut self, entry_id: u32) -> bool { | |
| 384 | 추가: if !self.model.can_extract() || self.opening.is_some() { | |
| 385 | 추가: return false; | |
| 386 | 추가: } | |
| 387 | 추가: let Some(entry) = self.model.entries.iter().find(|e| e.id == entry_id) else { | |
| 388 | 추가: return false; | |
| 389 | 추가: }; | |
| 390 | 추가: if entry.kind != Kind::File { | |
| 391 | 추가: return false; | |
| 392 | 추가: } | |
| 393 | 추가: let name = if self | |
| 394 | 추가: .model | |
| 395 | 추가: .list_id | |
| 396 | 추가: .as_ref() | |
| 397 | 추가: .is_some_and(|id| id.format == Format::Gzip) | |
| 398 | 추가: { | |
| 399 | 추가: self.gzip_name.clone() | |
| 400 | 추가: } else { | |
| 401 | 추가: entry.name.clone() | |
| 402 | 추가: }; | |
| 403 | 추가: if present::blocked_open(&name) { | |
| 404 | 추가: // 압축을 풀지 않고 바로 안내만 함. | |
| 405 | 추가: self.dismissed = false; | |
| 406 | 추가: self.ui_error = Some(present::open_blocked_text(&name)); | |
| 407 | 추가: return false; | |
| 408 | 추가: } | |
| 409 | 추가: let Some(archive) = self.model.archive.clone() else { | |
| 410 | 추가: return false; | |
| 411 | 추가: }; | |
| 412 | 추가: let root = match self.open_roots.iter().find(|(a, _)| *a == archive) { | |
| 413 | 추가: Some((_, root)) if root.is_dir() => root.clone(), | |
| 414 | 추가: _ => match present::create_open_root(&archive) { | |
| 415 | 추가: Ok(root) => { | |
| 416 | 추가: self.open_roots.retain(|(a, _)| *a != archive); | |
| 417 | 추가: self.open_roots.push((archive, root.clone())); | |
| 418 | 추가: root | |
| 419 | 추가: } | |
| 420 | 추가: Err(_) => { | |
| 421 | 추가: self.dismissed = false; | |
| 422 | 추가: self.ui_error = Some(present::FOLDER_ERROR.into()); | |
| 423 | 추가: return false; | |
| 424 | 추가: } | |
| 425 | 추가: }, | |
| 426 | 추가: }; | |
| 427 | 추가: // 같은 파일을 여러 번 열어도 충돌하지 않도록 열 때마다 새 하위 폴더에 풂. | |
| 428 | 추가: self.open_count += 1; | |
| 429 | 추가: let folder = present::unique_folder(&root.join(self.open_count.to_string())); | |
| 430 | 추가: let request = OpenRequest { | |
| 431 | 추가: folder: folder.clone(), | |
| 432 | 추가: name: name.replace('\\', "/"), | |
| 433 | 추가: destination: std::mem::replace(&mut self.destination, folder), | |
| 434 | 추가: automatic: std::mem::replace(&mut self.automatic_destination, true), | |
| 435 | 추가: }; | |
| 436 | 추가: self.opening = Some(request); | |
| 437 | 추가: if self.extract_selection(Selection::EntryIds(vec![entry_id])) { | |
| 438 | 추가: self.last_open = Some(entry_id); | |
| 439 | 추가: true | |
| 440 | 추가: } else { | |
| 441 | 추가: self.finish_open(false); | |
| 442 | 추가: false | |
| 443 | 추가: } | |
| 444 | 추가: } | |
| 445 | 추가: | |
| 446 | 추가: /// 열기용 풀기가 끝나면 원래 풀 위치를 되돌리고, 성공했으면 기본 프로그램을 실행함. | |
| 447 | 추가: fn finish_open(&mut self, completed: bool) { | |
| 448 | 추가: let Some(request) = self.opening.take() else { | |
| 449 | 추가: return; | |
| 450 | 추가: }; | |
| 451 | 추가: self.destination = request.destination; | |
| 452 | 추가: self.automatic_destination = request.automatic; | |
| 453 | 추가: if !completed { | |
| 454 | 추가: return; | |
| 455 | 추가: } | |
| 456 | 추가: let Some(name) = self | |
| 457 | 추가: .model | |
| 458 | 추가: .outputs | |
| 459 | 추가: .iter() | |
| 460 | 추가: .filter(|(_, d)| *d == Disposition::Created) | |
| 461 | 추가: .map(|(name, _)| name.replace('\\', "/")) | |
| 462 | 추가: .find(|name| name.trim_end_matches('/') == request.name) | |
| 463 | 추가: else { | |
| 464 | 추가: self.ui_error = Some(present::OPEN_MISSING.into()); | |
| 465 | 추가: return; | |
| 466 | 추가: }; | |
| 467 | 추가: let path = name | |
| 468 | 추가: .split('/') | |
| 469 | 추가: .fold(request.folder, |path, part| path.join(part)); | |
| 470 | 추가: match (self.opener)(&path) { | |
| 471 | 추가: // 결과 창 없이 바로 열린 파일을 보여 줌. | |
| 472 | 추가: Ok(()) => self.dismissed = true, | |
| 473 | 추가: Err(error) => self.ui_error = Some(error), | |
| 474 | 추가: } | |
| 475 | 추가: } | |
| 476 | 추가: | |
| 477 | 추가: /// 압축파일 이름으로 새 폴더를 만들고(같은 이름이 있으면 번호를 붙임) 선택 항목을 풂. | |
| 478 | 추가: fn extract_to_new_folder(&mut self) -> bool { | |
| 479 | 추가: let Some(archive) = self.model.archive.clone() else { | |
| 480 | 추가: return false; | |
| 481 | 추가: }; | |
| 482 | 추가: self.destination = present::unique_folder(&present::default_destination(&archive)); | |
| 483 | 추가: self.automatic_destination = true; | |
| 484 | 추가: self.begin_extract() | |
| 485 | 추가: } | |
| 486 | 추가: | |
| 347 | 487 | /// 창 순서를 지정할 수 없는 환경에서는 부모 안에 작업 화면을 그림. |
| 348 | 488 | pub fn set_work_window_in_parent(&mut self, enabled: bool) { |
| 349 | 489 | self.work_in_parent = enabled; |
| @@ -590,6 +730,9 @@ impl ArchiveApp { | ||
| 590 | 730 | return false; |
| 591 | 731 | } |
| 592 | 732 | self.selected_only = matches!(&selection, Selection::EntryIds(_)); |
| 733 | 추가: if self.opening.is_none() { | |
| 734 | 추가: self.last_open = None; | |
| 735 | 추가: } | |
| 593 | 736 | match present::prepare_destination(&self.destination, self.automatic_destination) { |
| 594 | 737 | Ok(true) => self.owned_destination = Some(self.destination.clone()), |
| 595 | 738 | Ok(false) => self.owned_destination = None, |
| @@ -806,6 +949,8 @@ impl ArchiveApp { | ||
| 806 | 949 | } |
| 807 | 950 | } |
| 808 | 951 | Purpose::Destination | Purpose::Retry => { |
| 952 | 추가: // 다른 폴더를 골랐으면 기본 프로그램 열기가 아닌 일반 풀기로 다시 함. | |
| 953 | 추가: self.last_open = None; | |
| 809 | 954 | self.choose_destination(path); |
| 810 | 955 | self.selected_only = !self.model.selected.is_empty(); |
| 811 | 956 | if purpose == Purpose::Retry { |
| @@ -862,6 +1007,9 @@ impl ArchiveApp { | ||
| 862 | 1007 | match request { |
| 863 | 1008 | Start::List { archive } => self.open_path(archive), |
| 864 | 1009 | Start::Preview { .. } | Start::RecoverZip { .. } => {} |
| 1010 | 추가: Start::Extract { .. } if let Some(entry_id) = self.last_open => { | |
| 1011 | 추가: self.open_entry(entry_id); | |
| 1012 | 추가: } | |
| 865 | 1013 | Start::Extract { |
| 866 | 1014 | selection, |
| 867 | 1015 | gzip_output_name, |
| @@ -918,6 +1066,17 @@ impl ArchiveApp { | ||
| 918 | 1066 | self.model.close = Close::Confirm; |
| 919 | 1067 | } |
| 920 | 1068 | if busy && !self.model.busy() { |
| 1069 | 추가: let completed = self.model.confirmed | |
| 1070 | 추가: && self | |
| 1071 | 추가: .model | |
| 1072 | 추가: .terminal | |
| 1073 | 추가: .as_ref() | |
| 1074 | 추가: .is_some_and(|t| t.outcome == Outcome::Completed); | |
| 1075 | 추가: if self.opening.is_some() { | |
| 1076 | 추가: // 열기용 폴더는 앱을 닫을 때 지우므로 풀 위치 소유 기록만 정리함. | |
| 1077 | 추가: self.owned_destination = None; | |
| 1078 | 추가: self.finish_open(completed); | |
| 1079 | 추가: } | |
| 921 | 1080 | if let Some(path) = self.owned_destination.take() { |
| 922 | 1081 | if !self.model.confirmed |
| 923 | 1082 | || self |
| @@ -1365,6 +1524,8 @@ impl ArchiveApp { | ||
| 1365 | 1524 | } |
| 1366 | 1525 | let mut focused = None; |
| 1367 | 1526 | let mut open = None; |
| 1527 | 추가: let mut open_file = None; | |
| 1528 | 추가: let mut menu_action = None; | |
| 1368 | 1529 | let mut next_offset = None; |
| 1369 | 1530 | let output = egui::ScrollArea::vertical() |
| 1370 | 1531 | .id_salt("archive-rows") |
| @@ -1386,7 +1547,12 @@ impl ArchiveApp { | ||
| 1386 | 1547 | && relative.x <= width |
| 1387 | 1548 | && relative.y >= 0.0 |
| 1388 | 1549 | && relative.y < rows.len() as f32 * LIST_ROW; |
| 1389 | 삭제: if clip.contains(press) && !in_row && ui.input(|i| i.pointer.primary_pressed()) | |
| 1550 | 추가: // 목록 위에 떠 있는 창(부모 안 작업 창 등)을 누른 경우는 목록 조작이 아님. | |
| 1551 | 추가: let on_list = ui.ctx().layer_id_at(press) == Some(ui.layer_id()); | |
| 1552 | 추가: if clip.contains(press) | |
| 1553 | 추가: && on_list | |
| 1554 | 추가: && !in_row | |
| 1555 | 추가: && ui.input(|i| i.pointer.primary_pressed()) | |
| 1390 | 1556 | { |
| 1391 | 1557 | background.request_focus(); |
| 1392 | 1558 | let ctrl = ui.input(|i| i.modifiers.ctrl || i.modifiers.command); |
| @@ -1499,8 +1665,26 @@ impl ArchiveApp { | ||
| 1499 | 1665 | modifiers.shift, |
| 1500 | 1666 | ); |
| 1501 | 1667 | } |
| 1502 | 삭제: if row.directory && response.double_clicked() { | |
| 1503 | 삭제: open = Some(row.path.clone()); | |
| 1668 | 추가: if response.double_clicked() { | |
| 1669 | 추가: if row.directory { | |
| 1670 | 추가: open = Some(row.path.clone()); | |
| 1671 | 추가: } else if let [id] = row.ids.iter().copied().collect::<Vec<_>>()[..] { | |
| 1672 | 추가: open_file = Some(id); | |
| 1673 | 추가: } | |
| 1674 | 추가: } | |
| 1675 | 추가: if active && response.secondary_clicked() && !selected { | |
| 1676 | 추가: // 선택하지 않은 행을 오른쪽 클릭하면 그 행만 선택한 뒤 메뉴를 엶. | |
| 1677 | 추가: self.select_row(&rows, index, false, false); | |
| 1678 | 추가: } | |
| 1679 | 추가: if active { | |
| 1680 | 추가: response.context_menu(|ui| { | |
| 1681 | 추가: if ui.button("압축 파일명으로 새 폴더를 만들어 압축 풀기").clicked() { | |
| 1682 | 추가: menu_action = Some(MenuAction::NewFolder); | |
| 1683 | 추가: } | |
| 1684 | 추가: if ui.button("특정 폴더에 압축 풀기").clicked() { | |
| 1685 | 추가: menu_action = Some(MenuAction::ChooseFolder); | |
| 1686 | 추가: } | |
| 1687 | 추가: }); | |
| 1504 | 1688 | } |
| 1505 | 1689 | // 암호가 걸린 항목은 이름 앞에 *를 붙이고, 툴팁은 실제 이름을 보여 줌. |
| 1506 | 1690 | let name = if row.encrypted { |
| @@ -1638,6 +1822,8 @@ impl ArchiveApp { | ||
| 1638 | 1822 | .min(rows.len() - 1); |
| 1639 | 1823 | if rows[index].directory { |
| 1640 | 1824 | open = Some(rows[index].path.clone()); |
| 1825 | 추가: } else if let [id] = rows[index].ids.iter().copied().collect::<Vec<_>>()[..] { | |
| 1826 | 추가: open_file = Some(id); | |
| 1641 | 1827 | } |
| 1642 | 1828 | } |
| 1643 | 1829 | } |
| @@ -1650,10 +1836,37 @@ impl ArchiveApp { | ||
| 1650 | 1836 | ); |
| 1651 | 1837 | } |
| 1652 | 1838 | } |
| 1839 | 추가: // 마우스 옆 버튼(뒤로)을 목록 위에서 누르면 상위 폴더로 이동함. | |
| 1840 | 추가: if active | |
| 1841 | 추가: && !self.folder.is_empty() | |
| 1842 | 추가: && ui.input(|i| { | |
| 1843 | 추가: i.pointer.button_pressed(egui::PointerButton::Extra1) | |
| 1844 | 추가: && i.pointer | |
| 1845 | 추가: .interact_pos() | |
| 1846 | 추가: .is_some_and(|pos| path_row.union(background.rect).contains(pos)) | |
| 1847 | 추가: }) | |
| 1848 | 추가: { | |
| 1849 | 추가: open = Some( | |
| 1850 | 추가: self.folder | |
| 1851 | 추가: .rsplit_once('/') | |
| 1852 | 추가: .map_or("", |(parent, _)| parent) | |
| 1853 | 추가: .to_owned(), | |
| 1854 | 추가: ); | |
| 1855 | 추가: } | |
| 1653 | 1856 | if let Some(folder) = open { |
| 1654 | 1857 | self.browse_folder(&folder); |
| 1655 | 1858 | background.request_focus(); |
| 1656 | 1859 | } |
| 1860 | 추가: if let Some(id) = open_file { | |
| 1861 | 추가: self.open_entry(id); | |
| 1862 | 추가: } | |
| 1863 | 추가: match menu_action { | |
| 1864 | 추가: Some(MenuAction::NewFolder) => { | |
| 1865 | 추가: self.extract_to_new_folder(); | |
| 1866 | 추가: } | |
| 1867 | 추가: Some(MenuAction::ChooseFolder) => self.open_picker(Purpose::Destination), | |
| 1868 | 추가: None => {} | |
| 1869 | 추가: } | |
| 1657 | 1870 | } |
| 1658 | 1871 | |
| 1659 | 1872 | fn clear_list_selection(&mut self) { |
| @@ -1966,9 +2179,13 @@ impl ArchiveApp { | ||
| 1966 | 2179 | }; |
| 1967 | 2180 | if self.work_in_parent { |
| 1968 | 2181 | // Wayland는 창 올리기를 지원하지 않으므로 부모 안에서 같은 내용을 그림. |
| 1969 | 삭제: let mut open = true; | |
| 1970 | 삭제: let mut window = egui::Window::new(RichText::new(title).size(theme::FONT_SMALL)) | |
| 2182 | 추가: // egui 기본 제목 줄의 닫기 버튼은 마우스를 올려도 모양이 바뀌지 않으므로 | |
| 2183 | 추가: // 제목 줄을 직접 그리고 별도 창과 같은 닫기 버튼을 씀. | |
| 2184 | 추가: let mut close = false; | |
| 2185 | 추가: let busy = self.model.busy(); | |
| 2186 | 추가: egui::Window::new(RichText::new(&title).size(theme::FONT_SMALL)) | |
| 1971 | 2187 | .id(egui::Id::new("archive-work-in-parent")) |
| 2188 | 추가: .title_bar(false) | |
| 1972 | 2189 | .default_pos( |
| 1973 | 2190 | ctx.content_rect().center() - egui::vec2(WORK_WIDTH, self.work.height) / 2.0, |
| 1974 | 2191 | ) |
| @@ -1980,21 +2197,26 @@ impl ArchiveApp { | ||
| 1980 | 2197 | .resizable(false) |
| 1981 | 2198 | .fade_in(false) |
| 1982 | 2199 | .fade_out(false) |
| 1983 | 삭제: .title_frame( | |
| 1984 | 삭제: theme::panel(theme::STRIPE) | |
| 1985 | 삭제: .inner_margin(egui::Margin::symmetric(16, 8)) | |
| 1986 | 삭제: .corner_radius(0), | |
| 1987 | 삭제: ) | |
| 1988 | 2200 | .frame( |
| 1989 | 삭제: theme::panel(theme::PANEL) | |
| 2201 | 추가: egui::Frame::new() | |
| 2202 | 추가: .fill(theme::PANEL) | |
| 1990 | 2203 | .stroke(egui::Stroke::new(1.0, theme::BORDER)) |
| 2204 | 추가: .inner_margin(egui::Margin::ZERO) | |
| 1991 | 2205 | .corner_radius(0), |
| 1992 | 삭제: ); | |
| 1993 | 삭제: if !self.model.busy() { | |
| 1994 | 삭제: window = window.open(&mut open); | |
| 1995 | 삭제: } | |
| 1996 | 삭제: window.show(ctx, |ui| self.work_area(ui)); | |
| 1997 | 삭제: if !open { | |
| 2206 | 추가: ) | |
| 2207 | 추가: .show(ctx, |ui| { | |
| 2208 | 추가: let spacing = ui.spacing().item_spacing.y; | |
| 2209 | 추가: ui.spacing_mut().item_spacing.y = 0.0; | |
| 2210 | 추가: close = window_frame::in_parent_title(ui, "work-in-parent", &title, !busy); | |
| 2211 | 추가: egui::Frame::new() | |
| 2212 | 추가: .inner_margin(egui::Margin::same(theme::PAD)) | |
| 2213 | 추가: .show(ui, |ui| { | |
| 2214 | 추가: ui.spacing_mut().item_spacing.y = spacing; | |
| 2215 | 추가: ui.set_width(WORK_WIDTH - 2.0 * theme::PAD as f32); | |
| 2216 | 추가: self.work_area(ui) | |
| 2217 | 추가: }); | |
| 2218 | 추가: }); | |
| 2219 | 추가: if close { | |
| 1998 | 2220 | self.dismissed = true; |
| 1999 | 2221 | self.ui_error = None; |
| 2000 | 2222 | self.model.input_error = None; |
| @@ -3435,5 +3657,8 @@ impl eframe::App for ArchiveApp { | ||
| 3435 | 3657 | impl Drop for ArchiveApp { |
| 3436 | 3658 | fn drop(&mut self) { |
| 3437 | 3659 | self.clear_password(); |
| 3660 | 추가: for (_, root) in self.open_roots.drain(..) { | |
| 3661 | 추가: present::remove_open_root(&root); | |
| 3662 | 추가: } | |
| 3438 | 3663 | } |
| 3439 | 3664 | } |
| @@ -11,6 +11,7 @@ pub const TITLE_HEIGHT: f32 = 38.0; | ||
| 11 | 11 | const BUTTON_SIZE: Vec2 = egui::vec2(34.0, 26.0); |
| 12 | 12 | const RESIZE_EDGE: f32 = 6.0; |
| 13 | 13 | const DRAG_THRESHOLD: f32 = 4.0; |
| 14 | 추가: const IN_PARENT_TITLE: f32 = 36.0; | |
| 14 | 15 | const TITLE_BG: Color32 = Color32::from_rgb(235, 238, 242); |
| 15 | 16 | |
| 16 | 17 | /// 창 테두리를 직접 그려야 하는지 판단함. |
| @@ -113,6 +114,35 @@ pub fn title_bar(root: &mut egui::Ui, id: &str, title: &str, buttons: Buttons) - | ||
| 113 | 114 | moved |
| 114 | 115 | } |
| 115 | 116 | |
| 117 | 추가: /// 부모 창 안에 그리는 자식 창의 제목 줄. 닫기 버튼을 누르면 true를 돌려줌. | |
| 118 | 추가: /// 별도 창의 제목 표시줄과 같은 닫기 버튼(마우스를 올리면 빨간 배경)을 씀. | |
| 119 | 추가: pub fn in_parent_title(ui: &mut egui::Ui, id: &str, title: &str, closable: bool) -> bool { | |
| 120 | 추가: let width = ui.available_width(); | |
| 121 | 추가: let (rect, _) = ui.allocate_exact_size(egui::vec2(width, IN_PARENT_TITLE), Sense::hover()); | |
| 122 | 추가: let painter = ui.painter(); | |
| 123 | 추가: painter.rect_filled(rect, 0.0, theme::STRIPE); | |
| 124 | 추가: painter.hline( | |
| 125 | 추가: rect.x_range(), | |
| 126 | 추가: rect.bottom() - 0.5, | |
| 127 | 추가: Stroke::new(1.0, theme::BORDER), | |
| 128 | 추가: ); | |
| 129 | 추가: let button = Rect::from_center_size( | |
| 130 | 추가: egui::pos2(rect.right() - 6.0 - BUTTON_SIZE.x / 2.0, rect.center().y), | |
| 131 | 추가: BUTTON_SIZE, | |
| 132 | 추가: ); | |
| 133 | 추가: let reserved = if closable { BUTTON_SIZE.x + 12.0 } else { 0.0 }; | |
| 134 | 추가: let font = FontId::proportional(theme::FONT_SMALL); | |
| 135 | 추가: let text = fit(ui, title, &font, (rect.width() - 32.0 - reserved).max(0.0)); | |
| 136 | 추가: ui.painter().text( | |
| 137 | 추가: egui::pos2(rect.left() + 16.0, rect.center().y), | |
| 138 | 추가: Align2::LEFT_CENTER, | |
| 139 | 추가: text, | |
| 140 | 추가: font, | |
| 141 | 추가: theme::TEXT, | |
| 142 | 추가: ); | |
| 143 | 추가: closable && window_button(ui, id, button, Glyph::Close).clicked() | |
| 144 | 추가: } | |
| 145 | 추가: | |
| 116 | 146 | /// 제목 표시줄을 누른 채 움직였는지를 원시 입력으로 판단함. |
| 117 | 147 | /// 창 이동 중에는 운영체제가 마우스를 가져가서 버튼 놓기가 앱에 오지 않으므로, |
| 118 | 148 | /// egui의 끌기 상태에 기대면 다음 끌기가 시작되지 않음. |
| @@ -287,3 +287,56 @@ fn explorer_folder_click_and_escape_control_actual_extraction_scope() { | ||
| 287 | 287 | )); |
| 288 | 288 | assert_reaped(&observed); |
| 289 | 289 | } |
| 290 | 추가: | |
| 291 | 추가: // 작업자는 새로 만든 상위 폴더도 출력으로 알림. 하위 폴더 안 파일도 그 파일 자체를 열어야 함. | |
| 292 | 추가: #[test] | |
| 293 | 추가: fn double_click_open_extracts_nested_file_and_opens_that_file() { | |
| 294 | 추가: let scratch = Scratch::new(); | |
| 295 | 추가: let folder = make_directory(&scratch.path("site")); | |
| 296 | 추가: fs::write(folder.join("index.html"), b"<p>zipelo</p>").unwrap(); | |
| 297 | 추가: fs::write(folder.join("style.css"), b"p{}").unwrap(); | |
| 298 | 추가: let archive = scratch.path("site.zip"); | |
| 299 | 추가: let (factory, observed) = observed_factory(); | |
| 300 | 추가: let mut screen = Screen::new(factory); | |
| 301 | 추가: let opened = std::rc::Rc::new(std::cell::RefCell::new(Vec::new())); | |
| 302 | 추가: let record = opened.clone(); | |
| 303 | 추가: screen.app.set_opener(Box::new(move |path| { | |
| 304 | 추가: record.borrow_mut().push(path.to_path_buf()); | |
| 305 | 추가: Ok(()) | |
| 306 | 추가: })); | |
| 307 | 추가: screen.app.add_sources(vec![folder]); | |
| 308 | 추가: screen.render(vec![]); | |
| 309 | 추가: screen.set_text("zip-name", "site.zip"); | |
| 310 | 추가: screen.click("압축하기"); | |
| 311 | 추가: screen.settle(); | |
| 312 | 추가: screen.open(&archive); | |
| 313 | 추가: for name in ["site/index.html", "site/style.css"] { | |
| 314 | 추가: let id = screen | |
| 315 | 추가: .app | |
| 316 | 추가: .model | |
| 317 | 추가: .entries | |
| 318 | 추가: .iter() | |
| 319 | 추가: .find(|entry| entry.name == name) | |
| 320 | 추가: .unwrap() | |
| 321 | 추가: .id; | |
| 322 | 추가: assert!(screen.app.open_entry(id)); | |
| 323 | 추가: screen.settle(); | |
| 324 | 추가: screen.render(vec![]); | |
| 325 | 추가: } | |
| 326 | 추가: let root = scratch.path("site.zip (Zipelo 임시)"); | |
| 327 | 추가: assert_eq!( | |
| 328 | 추가: *opened.borrow(), | |
| 329 | 추가: vec![ | |
| 330 | 추가: root.join("1/site/index.html"), | |
| 331 | 추가: root.join("2/site/style.css") | |
| 332 | 추가: ] | |
| 333 | 추가: ); | |
| 334 | 추가: assert_eq!( | |
| 335 | 추가: fs::read(root.join("1/site/index.html")).unwrap(), | |
| 336 | 추가: b"<p>zipelo</p>" | |
| 337 | 추가: ); | |
| 338 | 추가: assert!(!root.join("1/site/style.css").exists()); | |
| 339 | 추가: assert_reaped(&observed); | |
| 340 | 추가: drop(screen); | |
| 341 | 추가: assert!(!root.exists()); | |
| 342 | 추가: } |
| @@ -3,6 +3,7 @@ struct Explorer { | ||
| 3 | 3 | ctx: egui::Context, |
| 4 | 4 | factory: FakeFactory, |
| 5 | 5 | time: f64, |
| 6 | 추가: opened: std::rc::Rc<std::cell::RefCell<Vec<PathBuf>>>, | |
| 6 | 7 | } |
| 7 | 8 | impl Explorer { |
| 8 | 9 | fn new(scratch: &Folder) -> Self { |
| @@ -25,11 +26,18 @@ impl Explorer { | ||
| 25 | 26 | encrypted: false, |
| 26 | 27 | }) |
| 27 | 28 | .into(); |
| 29 | 추가: let opened = std::rc::Rc::new(std::cell::RefCell::new(Vec::new())); | |
| 30 | 추가: let record = opened.clone(); | |
| 31 | 추가: app.set_opener(Box::new(move |path| { | |
| 32 | 추가: record.borrow_mut().push(path.to_path_buf()); | |
| 33 | 추가: Ok(()) | |
| 34 | 추가: })); | |
| 28 | 35 | let mut screen = Self { |
| 29 | 36 | app, |
| 30 | 37 | ctx: egui::Context::default(), |
| 31 | 38 | factory, |
| 32 | 39 | time: 0.0, |
| 40 | 추가: opened, | |
| 33 | 41 | }; |
| 34 | 42 | screen.frame(egui::Modifiers::NONE, vec![]); |
| 35 | 43 | screen.frame(egui::Modifiers::NONE, vec![]); |
| @@ -115,6 +123,44 @@ impl Explorer { | ||
| 115 | 123 | }], |
| 116 | 124 | ); |
| 117 | 125 | } |
| 126 | 추가: fn button(&mut self, point: egui::Pos2, button: egui::PointerButton) { | |
| 127 | 추가: self.time += 1.0; | |
| 128 | 추가: for pressed in [true, false] { | |
| 129 | 추가: self.frame( | |
| 130 | 추가: egui::Modifiers::NONE, | |
| 131 | 추가: vec![ | |
| 132 | 추가: egui::Event::PointerMoved(point), | |
| 133 | 추가: egui::Event::PointerButton { | |
| 134 | 추가: pos: point, | |
| 135 | 추가: button, | |
| 136 | 추가: pressed, | |
| 137 | 추가: modifiers: egui::Modifiers::NONE, | |
| 138 | 추가: }, | |
| 139 | 추가: ], | |
| 140 | 추가: ); | |
| 141 | 추가: } | |
| 142 | 추가: self.frame(egui::Modifiers::NONE, vec![]); | |
| 143 | 추가: } | |
| 144 | 추가: fn double_click(&mut self, path: &str) { | |
| 145 | 추가: self.time += 1.0; | |
| 146 | 추가: let point = self.row(path).center(); | |
| 147 | 추가: for _ in 0..2 { | |
| 148 | 추가: self.pointer(point, true, egui::Modifiers::NONE); | |
| 149 | 추가: self.pointer(point, false, egui::Modifiers::NONE); | |
| 150 | 추가: } | |
| 151 | 추가: for _ in 0..30 { | |
| 152 | 추가: self.frame(egui::Modifiers::NONE, vec![]); | |
| 153 | 추가: } | |
| 154 | 추가: } | |
| 155 | 추가: fn click_text(&mut self, label: &str) { | |
| 156 | 추가: let output = self.frame(egui::Modifiers::NONE, vec![]); | |
| 157 | 추가: let rect = layout_text(&output) | |
| 158 | 추가: .into_iter() | |
| 159 | 추가: .find(|(text, _, _)| text == label) | |
| 160 | 추가: .unwrap_or_else(|| panic!("{label} 없음")) | |
| 161 | 추가: .1; | |
| 162 | 추가: self.button(rect.center(), egui::PointerButton::Primary); | |
| 163 | 추가: } | |
| 118 | 164 | #[track_caller] |
| 119 | 165 | fn selected(&self, ids: &[u32]) { |
| 120 | 166 | assert_eq!(self.app.model.selected, ids.iter().copied().collect()); |
| @@ -222,16 +268,215 @@ fn explorer_keyboard_ranges_enter_backspace_and_escape_are_scoped_to_the_list() | ||
| 222 | 268 | } |
| 223 | 269 | |
| 224 | 270 | #[test] |
| 225 | 삭제: fn explorer_double_click_opens_only_folders_and_resets_selection() { | |
| 271 | 추가: fn explorer_double_click_opens_files_with_default_app_and_folders_in_place() { | |
| 226 | 272 | let scratch = Folder::new(); |
| 227 | 273 | let mut s = Explorer::new(&scratch); |
| 228 | 삭제: let point = s.row("alpha.txt").center(); | |
| 229 | 삭제: for _ in 0..2 { | |
| 230 | 삭제: s.pointer(point, true, egui::Modifiers::NONE); | |
| 231 | 삭제: s.pointer(point, false, egui::Modifiers::NONE); | |
| 274 | 추가: let destination = s.app.model.archive.clone().unwrap().with_file_name("sample"); | |
| 275 | 추가: // 실제 작업자처럼 새로 만든 상위 폴더도 출력으로 알림. | |
| 276 | 추가: s.factory.state.borrow_mut().outputs = Some(vec!["docs".into(), "docs/child.txt".into()]); | |
| 277 | 추가: s.app.browse_folder("docs"); | |
| 278 | 추가: s.double_click("docs/child.txt"); | |
| 279 | 추가: s.selected(&[0]); | |
| 280 | 추가: // 파일은 압축파일 옆 숨김 임시 폴더에 그 파일만 풀고 기본 프로그램으로 엶. | |
| 281 | 추가: let root = scratch.0.join("sample.zip (Zipelo 임시)"); | |
| 282 | 추가: { | |
| 283 | 추가: let state = s.factory.state.borrow(); | |
| 284 | 추가: assert_eq!(state.starts.len(), 2); | |
| 285 | 추가: let Start::Extract { | |
| 286 | 추가: destination: folder, | |
| 287 | 추가: selection, | |
| 288 | 추가: .. | |
| 289 | 추가: } = state.starts.last().unwrap() | |
| 290 | 추가: else { | |
| 291 | 추가: panic!("{:?}", state.starts.last()); | |
| 292 | 추가: }; | |
| 293 | 추가: assert_eq!(selection, &Selection::EntryIds(vec![0])); | |
| 294 | 추가: assert_eq!(folder, &root.join("1")); | |
| 232 | 295 | } |
| 233 | 삭제: s.selected(&[1]); | |
| 296 | 추가: assert_eq!( | |
| 297 | 추가: *s.opened.borrow(), | |
| 298 | 추가: vec![root.join("1").join("docs").join("child.txt")] | |
| 299 | 추가: ); | |
| 300 | 추가: let output = s.frame(egui::Modifiers::NONE, vec![]); | |
| 301 | 추가: assert!( | |
| 302 | 추가: !layout_text(&output) | |
| 303 | 추가: .iter() | |
| 304 | 추가: .any(|(text, _, _)| text == "작업 결과") | |
| 305 | 추가: ); | |
| 306 | 추가: // 같은 파일을 다시 열면 새 하위 폴더를 씀. | |
| 307 | 추가: s.double_click("docs/child.txt"); | |
| 308 | 추가: assert!(matches!( | |
| 309 | 추가: s.factory.state.borrow().starts.last(), | |
| 310 | 추가: Some(Start::Extract { destination, .. }) if destination == &root.join("2") | |
| 311 | 추가: )); | |
| 312 | 추가: assert_eq!(s.opened.borrow().len(), 2); | |
| 313 | 추가: // 열 파일이 출력에 없으면 조용히 넘어가지 않고 알림. | |
| 314 | 추가: s.factory.state.borrow_mut().outputs = Some(vec!["docs".into()]); | |
| 315 | 추가: s.double_click("docs/child.txt"); | |
| 316 | 추가: assert_eq!(s.opened.borrow().len(), 2); | |
| 317 | 추가: assert!( | |
| 318 | 추가: layout_text(&s.frame(egui::Modifiers::NONE, vec![])) | |
| 319 | 추가: .iter() | |
| 320 | 추가: .any(|(text, _, _)| text == "풀린 파일을 찾지 못해 열지 못했습니다") | |
| 321 | 추가: ); | |
| 322 | 추가: // 열기용 폴더는 압축파일 이름 폴더와 섞이지 않음. | |
| 323 | 추가: assert!(!destination.exists()); | |
| 324 | 추가: // 앱을 닫으면 열기용 폴더를 지움. | |
| 325 | 추가: assert!(root.is_dir()); | |
| 326 | 추가: drop(s); | |
| 327 | 추가: assert!(!root.exists()); | |
| 328 | 추가: } | |
| 329 | 추가: | |
| 330 | 추가: #[test] | |
| 331 | 추가: fn explorer_double_click_does_not_open_executables() { | |
| 332 | 추가: let scratch = Folder::new(); | |
| 333 | 추가: let mut s = Explorer::new(&scratch); | |
| 334 | 추가: s.app.model.entries[2].name = "setup.EXE".into(); | |
| 335 | 추가: s.double_click("setup.EXE"); | |
| 234 | 336 | assert_eq!(s.factory.state.borrow().starts.len(), 1); |
| 337 | 추가: assert!(s.opened.borrow().is_empty()); | |
| 338 | 추가: let output = s.frame(egui::Modifiers::NONE, vec![]); | |
| 339 | 추가: assert!( | |
| 340 | 추가: layout_text(&output) | |
| 341 | 추가: .iter() | |
| 342 | 추가: .any(|(text, _, _)| text == "실행 파일(.EXE)은 안전을 위해 바로 열 수 없습니다") | |
| 343 | 추가: ); | |
| 344 | 추가: // 실행 파일은 압축을 풀지 않으므로 임시 폴더도 만들지 않음. | |
| 345 | 추가: assert!(!scratch.0.join("sample.zip (Zipelo 임시)").exists()); | |
| 346 | 추가: } | |
| 347 | 추가: | |
| 348 | 추가: #[test] | |
| 349 | 추가: fn explorer_dragging_in_parent_work_window_does_not_select_rows() { | |
| 350 | 추가: let scratch = Folder::new(); | |
| 351 | 추가: let mut s = Explorer::new(&scratch); | |
| 352 | 추가: s.app.set_work_window_in_parent(true); | |
| 353 | 추가: s.app.model.entries[2].name = "setup.EXE".into(); | |
| 354 | 추가: s.double_click("setup.EXE"); | |
| 355 | 추가: s.selected(&[2]); | |
| 356 | 추가: let close = s | |
| 357 | 추가: .ctx | |
| 358 | 추가: .read_response(egui::Id::unique(("window-button", "work-in-parent", "닫기"))) | |
| 359 | 추가: .expect("부모 안 작업 창") | |
| 360 | 추가: .rect; | |
| 361 | 추가: // 행이 하나뿐인 폴더로 옮겨 작업 창 제목 줄 아래가 목록의 빈 곳이 되게 함. | |
| 362 | 추가: s.app.browse_folder("docs"); | |
| 363 | 추가: let row = s.row("docs/child.txt"); | |
| 364 | 추가: s.selected(&[]); | |
| 365 | 추가: // 작업 창 제목 줄을 누르고 목록 행 위로 끌어도 목록 선택 사각형이 생기지 않아야 함. | |
| 366 | 추가: let start = egui::pos2(close.left() - 120.0, close.center().y); | |
| 367 | 추가: assert!(start.y > row.bottom(), "{start:?} {row:?}"); | |
| 368 | 추가: s.pointer(start, true, egui::Modifiers::NONE); | |
| 369 | 추가: let end = egui::pos2(row.center().x, row.center().y); | |
| 370 | 추가: for step in 1..=6 { | |
| 371 | 추가: let t = step as f32 / 6.0; | |
| 372 | 추가: s.frame( | |
| 373 | 추가: egui::Modifiers::NONE, | |
| 374 | 추가: vec![egui::Event::PointerMoved(start + (end - start) * t)], | |
| 375 | 추가: ); | |
| 376 | 추가: } | |
| 377 | 추가: let output = s.frame(egui::Modifiers::NONE, vec![]); | |
| 378 | 추가: s.selected(&[]); | |
| 379 | 추가: assert!(!output.shapes.iter().any(|shape| matches!( | |
| 380 | 추가: &shape.shape, | |
| 381 | 추가: egui::epaint::Shape::Rect(rect) if rect.fill == theme_blue_fill() | |
| 382 | 추가: ))); | |
| 383 | 추가: s.pointer(end, false, egui::Modifiers::NONE); | |
| 384 | 추가: s.selected(&[]); | |
| 385 | 추가: } | |
| 386 | 추가: | |
| 387 | 추가: fn theme_blue_fill() -> egui::Color32 { | |
| 388 | 추가: zipelo_ui_memory_app::archive_theme::BLUE.gamma_multiply(0.16) | |
| 389 | 추가: } | |
| 390 | 추가: | |
| 391 | 추가: #[test] | |
| 392 | 추가: fn explorer_context_menu_extracts_selection_into_numbered_archive_folder() { | |
| 393 | 추가: let scratch = Folder::new(); | |
| 394 | 추가: let mut s = Explorer::new(&scratch); | |
| 395 | 추가: fs::create_dir(scratch.0.join("sample")).unwrap(); | |
| 396 | 추가: s.click("alpha.txt", egui::Modifiers::NONE); | |
| 397 | 추가: // 선택하지 않은 행을 오른쪽 클릭하면 그 행만 선택하고 메뉴를 엶. | |
| 398 | 추가: let point = s.row("docs").center(); | |
| 399 | 추가: s.button(point, egui::PointerButton::Secondary); | |
| 400 | 추가: s.selected(&[0, 5]); | |
| 401 | 추가: s.click_text("압축 파일명으로 새 폴더를 만들어 압축 풀기"); | |
| 402 | 추가: for _ in 0..30 { | |
| 403 | 추가: s.frame(egui::Modifiers::NONE, vec![]); | |
| 404 | 추가: } | |
| 405 | 추가: let state = s.factory.state.borrow(); | |
| 406 | 추가: let Some(Start::Extract { | |
| 407 | 추가: destination, | |
| 408 | 추가: selection, | |
| 409 | 추가: .. | |
| 410 | 추가: }) = state.starts.last() | |
| 411 | 추가: else { | |
| 412 | 추가: panic!("{:?}", state.starts.last()); | |
| 413 | 추가: }; | |
| 414 | 추가: assert_eq!(destination, &scratch.0.join("sample (1)")); | |
| 415 | 추가: assert_eq!(selection, &Selection::EntryIds(vec![0, 5])); | |
| 416 | 추가: assert!(scratch.0.join("sample (1)").is_dir()); | |
| 417 | 추가: assert!(s.opened.borrow().is_empty()); | |
| 418 | 추가: } | |
| 419 | 추가: | |
| 420 | 추가: #[test] | |
| 421 | 추가: fn explorer_context_menu_asks_for_folder_and_extracts_only_selection() { | |
| 422 | 추가: let scratch = Folder::new(); | |
| 423 | 추가: let mut s = Explorer::new(&scratch); | |
| 424 | 추가: let dialogs = crate::dialogs::TestDialogs::default(); | |
| 425 | 추가: let target = scratch.0.join("target"); | |
| 426 | 추가: fs::create_dir(&target).unwrap(); | |
| 427 | 추가: dialogs | |
| 428 | 추가: .0 | |
| 429 | 추가: .borrow_mut() | |
| 430 | 추가: .answers | |
| 431 | 추가: .push_back(Some(vec![target.clone()])); | |
| 432 | 추가: s.app.set_dialogs(Box::new(dialogs.clone())); | |
| 433 | 추가: s.click("alpha.txt", egui::Modifiers::NONE); | |
| 434 | 추가: s.click("beta.txt", explorer_ctrl()); | |
| 435 | 추가: let point = s.row("beta.txt").center(); | |
| 436 | 추가: s.button(point, egui::PointerButton::Secondary); | |
| 437 | 추가: s.selected(&[1, 2]); | |
| 438 | 추가: s.click_text("특정 폴더에 압축 풀기"); | |
| 439 | 추가: for _ in 0..30 { | |
| 440 | 추가: s.frame(egui::Modifiers::NONE, vec![]); | |
| 441 | 추가: } | |
| 442 | 추가: assert_eq!( | |
| 443 | 추가: dialogs.0.borrow().requests.last().unwrap().purpose, | |
| 444 | 추가: zipelo_ui_memory_app::archive_dialog::Purpose::Destination | |
| 445 | 추가: ); | |
| 446 | 추가: assert!(matches!( | |
| 447 | 추가: s.factory.state.borrow().starts.last(), | |
| 448 | 추가: Some(Start::Extract { destination, selection: Selection::EntryIds(ids), .. }) | |
| 449 | 추가: if destination == &target && ids == &vec![1, 2] | |
| 450 | 추가: )); | |
| 451 | 추가: } | |
| 452 | 추가: | |
| 453 | 추가: #[test] | |
| 454 | 추가: fn explorer_mouse_back_button_goes_to_parent_folder() { | |
| 455 | 추가: let scratch = Folder::new(); | |
| 456 | 추가: let mut s = Explorer::new(&scratch); | |
| 457 | 추가: s.app.browse_folder("docs"); | |
| 458 | 추가: let point = s.row("docs/child.txt").center(); | |
| 459 | 추가: s.button(point, egui::PointerButton::Extra2); | |
| 460 | 추가: assert!(s.ctx.read_response(egui::Id::unique(("archive-row", "docs/child.txt"))).is_some()); | |
| 461 | 추가: s.button(point, egui::PointerButton::Extra1); | |
| 462 | 추가: assert!( | |
| 463 | 추가: layout_text(&s.frame(egui::Modifiers::NONE, vec![])) | |
| 464 | 추가: .iter() | |
| 465 | 추가: .any(|(text, _, _)| text == "alpha.txt") | |
| 466 | 추가: ); | |
| 467 | 추가: // 최상위에서는 아무 일도 하지 않음. | |
| 468 | 추가: s.button(point, egui::PointerButton::Extra1); | |
| 469 | 추가: assert!( | |
| 470 | 추가: layout_text(&s.frame(egui::Modifiers::NONE, vec![])) | |
| 471 | 추가: .iter() | |
| 472 | 추가: .any(|(text, _, _)| text == "alpha.txt") | |
| 473 | 추가: ); | |
| 474 | 추가: } | |
| 475 | 추가: | |
| 476 | 추가: #[test] | |
| 477 | 추가: fn explorer_double_click_opens_only_folders_and_resets_selection() { | |
| 478 | 추가: let scratch = Folder::new(); | |
| 479 | 추가: let mut s = Explorer::new(&scratch); | |
| 235 | 480 | s.time += 1.0; |
| 236 | 481 | let point = s.row("docs").center(); |
| 237 | 482 | for _ in 0..2 { |
| @@ -18,6 +18,8 @@ pub struct State { | ||
| 18 | 18 | pub list_format: Option<Format>, |
| 19 | 19 | pub fail_start: bool, |
| 20 | 20 | pub dropped_connections: usize, |
| 21 | 추가: /// 풀기 출력으로 알릴 이름. 없으면 "읽어주세요.txt" 하나를 알림. | |
| 22 | 추가: pub outputs: Option<Vec<String>>, | |
| 21 | 23 | pause: bool, |
| 22 | 24 | } |
| 23 | 25 | #[derive(Default, Clone)] |
| @@ -132,11 +134,17 @@ impl State { | ||
| 132 | 134 | total: Some(31), |
| 133 | 135 | completed_entries: 1, |
| 134 | 136 | }); |
| 135 | 삭제: self.frame(Event::Output { | |
| 136 | 삭제: entry_id: Some(0), | |
| 137 | 삭제: relative_name: "읽어주세요.txt".into(), | |
| 138 | 삭제: disposition: Disposition::Created, | |
| 139 | 삭제: }); | |
| 137 | 추가: let names = self | |
| 138 | 추가: .outputs | |
| 139 | 추가: .clone() | |
| 140 | 추가: .unwrap_or_else(|| vec!["읽어주세요.txt".into()]); | |
| 141 | 추가: for name in names { | |
| 142 | 추가: self.frame(Event::Output { | |
| 143 | 추가: entry_id: None, | |
| 144 | 추가: relative_name: name, | |
| 145 | 추가: disposition: Disposition::Created, | |
| 146 | 추가: }); | |
| 147 | 추가: } | |
| 140 | 148 | self.finish(Outcome::Completed, Publication::Complete); |
| 141 | 149 | } |
| 142 | 150 | } |
| @@ -333,6 +333,19 @@ fn default_names_and_middle_truncation_preserve_unicode() { | ||
| 333 | 333 | assert_eq!(default_destination(&path(name)), path("압축 해제")); |
| 334 | 334 | } |
| 335 | 335 | assert_eq!(default_destination(&path("자료.zip")), path("자료")); |
| 336 | 추가: assert!(blocked_open("폴더/setup.EXE")); | |
| 337 | 추가: assert!(blocked_open("run.desktop")); | |
| 338 | 추가: assert!(!blocked_open("사진.jpg")); | |
| 339 | 추가: assert!(!blocked_open("exe")); | |
| 340 | 추가: // Linux는 스크립트를 편집기로 열므로 막지 않음. | |
| 341 | 추가: #[cfg(not(windows))] | |
| 342 | 추가: assert!(!blocked_open("app.js")); | |
| 343 | 추가: #[cfg(windows)] | |
| 344 | 추가: assert!(blocked_open("app.js")); | |
| 345 | 추가: assert_eq!( | |
| 346 | 추가: open_blocked_text("폴더/setup.EXE"), | |
| 347 | 추가: "실행 파일(.EXE)은 안전을 위해 바로 열 수 없습니다" | |
| 348 | 추가: ); | |
| 336 | 349 | assert_eq!(middle_text("가나다라마바사아자차", 7), "가나다…아자차"); |
| 337 | 350 | assert_eq!(bytes_text(21), "21 B"); |
| 338 | 351 | } |
| @@ -358,6 +371,17 @@ impl Drop for Folder { | ||
| 358 | 371 | } |
| 359 | 372 | } |
| 360 | 373 | |
| 374 | 추가: #[test] | |
| 375 | 추가: fn unique_folder_numbers_existing_names() { | |
| 376 | 추가: let scratch = Folder::new(); | |
| 377 | 추가: let base = scratch.0.join("자료"); | |
| 378 | 추가: assert_eq!(unique_folder(&base), base); | |
| 379 | 추가: fs::create_dir(&base).unwrap(); | |
| 380 | 추가: assert_eq!(unique_folder(&base), scratch.0.join("자료 (1)")); | |
| 381 | 추가: fs::write(scratch.0.join("자료 (1)"), b"").unwrap(); | |
| 382 | 추가: assert_eq!(unique_folder(&base), scratch.0.join("자료 (2)")); | |
| 383 | 추가: } | |
| 384 | 추가: | |
| 361 | 385 | #[test] |
| 362 | 386 | fn automatic_destination_creation_and_failure_are_distinct() { |
| 363 | 387 | let scratch = Folder::new(); |
| @@ -938,3 +938,86 @@ fn scenario_window_hosting_survives_platform_frame_configuration() { | ||
| 938 | 938 | } |
| 939 | 939 | } |
| 940 | 940 | } |
| 941 | 추가: | |
| 942 | 추가: #[test] | |
| 943 | 추가: fn hosted_work_window_close_button_shows_hover_and_dismisses_result() { | |
| 944 | 추가: let factory = FakeFactory::manual(); | |
| 945 | 추가: let mut app = ArchiveApp::new(Box::new(factory.clone()), Some("/sample.zip".into()), false); | |
| 946 | 추가: app.set_work_window_in_parent(true); | |
| 947 | 추가: let ctx = egui::Context::default(); | |
| 948 | 추가: ctx.set_embed_viewports(false); | |
| 949 | 추가: install_work_child_renderer(); | |
| 950 | 추가: { | |
| 951 | 추가: let mut worker = factory.state.borrow_mut(); | |
| 952 | 추가: worker.finish(Outcome::Failed, Publication::None); | |
| 953 | 추가: for event in &mut worker.queue { | |
| 954 | 추가: if let HostEvent::Frame { | |
| 955 | 추가: event: Event::Terminal(terminal), | |
| 956 | 추가: .. | |
| 957 | 추가: } = event | |
| 958 | 추가: { | |
| 959 | 추가: terminal.error = Some(ErrorCode::Io); | |
| 960 | 추가: } | |
| 961 | 추가: } | |
| 962 | 추가: } | |
| 963 | 추가: let render = |app: &mut ArchiveApp, events: Vec<egui::Event>| { | |
| 964 | 추가: let mut output = ctx.run_ui( | |
| 965 | 추가: egui::RawInput { | |
| 966 | 추가: screen_rect: Some(egui::Rect::from_min_size( | |
| 967 | 추가: egui::Pos2::ZERO, | |
| 968 | 추가: egui::vec2(1060.0, 720.0), | |
| 969 | 추가: )), | |
| 970 | 추가: events, | |
| 971 | 추가: ..Default::default() | |
| 972 | 추가: }, | |
| 973 | 추가: |ui| app.show(ui), | |
| 974 | 추가: ); | |
| 975 | 추가: output.textures_delta.clear(); | |
| 976 | 추가: output | |
| 977 | 추가: }; | |
| 978 | 추가: for _ in 0..4 { | |
| 979 | 추가: render(&mut app, vec![]); | |
| 980 | 추가: } | |
| 981 | 추가: let close_id = egui::Id::unique(("window-button", "work-in-parent", "닫기")); | |
| 982 | 추가: let close = ctx.read_response(close_id).expect("닫기 버튼").rect; | |
| 983 | 추가: let red = egui::Color32::from_rgb(232, 17, 35); | |
| 984 | 추가: fn has_fill(shapes: &[egui::epaint::ClippedShape], color: egui::Color32) -> bool { | |
| 985 | 추가: fn walk(shape: &Shape, color: egui::Color32) -> bool { | |
| 986 | 추가: match shape { | |
| 987 | 추가: Shape::Rect(rect) => rect.fill == color, | |
| 988 | 추가: Shape::Vec(shapes) => shapes.iter().any(|s| walk(s, color)), | |
| 989 | 추가: _ => false, | |
| 990 | 추가: } | |
| 991 | 추가: } | |
| 992 | 추가: shapes.iter().any(|s| walk(&s.shape, color)) | |
| 993 | 추가: } | |
| 994 | 추가: let idle = render(&mut app, vec![egui::Event::PointerMoved(egui::pos2(5.0, 5.0))]); | |
| 995 | 추가: assert!(!has_fill(&idle.shapes, red)); | |
| 996 | 추가: assert!( | |
| 997 | 추가: labels(&idle.shapes) | |
| 998 | 추가: .iter() | |
| 999 | 추가: .any(|(text, _)| text == "압축파일을 열지 못했습니다") | |
| 1000 | 추가: ); | |
| 1001 | 추가: render(&mut app, vec![egui::Event::PointerMoved(close.center())]); | |
| 1002 | 추가: let hovered = render(&mut app, vec![]); | |
| 1003 | 추가: assert!(has_fill(&hovered.shapes, red)); | |
| 1004 | 추가: for pressed in [true, false] { | |
| 1005 | 추가: render( | |
| 1006 | 추가: &mut app, | |
| 1007 | 추가: vec![egui::Event::PointerButton { | |
| 1008 | 추가: pos: close.center(), | |
| 1009 | 추가: button: egui::PointerButton::Primary, | |
| 1010 | 추가: pressed, | |
| 1011 | 추가: modifiers: egui::Modifiers::NONE, | |
| 1012 | 추가: }], | |
| 1013 | 추가: ); | |
| 1014 | 추가: } | |
| 1015 | 추가: render(&mut app, vec![]); | |
| 1016 | 추가: let shown = labels(&render(&mut app, vec![]).shapes); | |
| 1017 | 추가: assert!( | |
| 1018 | 추가: !shown | |
| 1019 | 추가: .iter() | |
| 1020 | 추가: .any(|(text, _)| text == "압축파일을 열지 못했습니다"), | |
| 1021 | 추가: "{shown:?}" | |
| 1022 | 추가: ); | |
| 1023 | 추가: } |
| @@ -519,6 +519,46 @@ fn symlink_parent_escape_is_rejected() { | ||
| 519 | 519 | assert_eq!(fs::read_dir(s.0.join("outside")).unwrap().count(), 0); |
| 520 | 520 | } |
| 521 | 521 | |
| 522 | 추가: // umask 002에서 폴더 선택 창으로 새로 만든 폴더(775)에도 풀 수 있어야 함. | |
| 523 | 추가: // 다른 계정이 쓸 수 있는 폴더(777)는 계속 거부함. | |
| 524 | 추가: #[cfg(target_os = "linux")] | |
| 525 | 추가: #[test] | |
| 526 | 추가: fn private_group_writable_output_is_accepted() { | |
| 527 | 추가: use std::os::unix::fs::{MetadataExt, PermissionsExt}; | |
| 528 | 추가: for (mode, other) in [(0o775, false), (0o777, true)] { | |
| 529 | 추가: let s = Scratch::new(); | |
| 530 | 추가: fs::create_dir(s.0.join("output")).unwrap(); | |
| 531 | 추가: fs::set_permissions(s.0.join("output"), fs::Permissions::from_mode(mode)).unwrap(); | |
| 532 | 추가: let gid = fs::metadata(s.0.join("output")).unwrap().gid(); | |
| 533 | 추가: let entry = Command::new("getent") | |
| 534 | 추가: .args(["group", &gid.to_string()]) | |
| 535 | 추가: .output() | |
| 536 | 추가: .unwrap(); | |
| 537 | 추가: let entry = String::from_utf8_lossy(&entry.stdout); | |
| 538 | 추가: let egid = Command::new("id").arg("-g").output().unwrap(); | |
| 539 | 추가: let private = String::from_utf8_lossy(&egid.stdout).trim() == gid.to_string() | |
| 540 | 추가: && entry.trim_end().ends_with(':'); | |
| 541 | 추가: let e = extract( | |
| 542 | 추가: &s, | |
| 543 | 추가: include_bytes!("fixtures/store.zip"), | |
| 544 | 추가: None, | |
| 545 | 추가: Selection::All, | |
| 546 | 추가: None, | |
| 547 | 추가: Limits::default(), | |
| 548 | 추가: ); | |
| 549 | 추가: if other || !private { | |
| 550 | 추가: assert_eq!(terminal(&e).error, ErrorCode::UnsafePath, "{mode:o}"); | |
| 551 | 추가: assert!(!s.0.join("output/folder").exists()); | |
| 552 | 추가: } else { | |
| 553 | 추가: assert_eq!(terminal(&e).outcome, Outcome::Completed, "{e:?}"); | |
| 554 | 추가: assert_eq!( | |
| 555 | 추가: fs::read(s.0.join("output/folder/hello.txt")).unwrap(), | |
| 556 | 추가: PAYLOAD | |
| 557 | 추가: ); | |
| 558 | 추가: } | |
| 559 | 추가: } | |
| 560 | 추가: } | |
| 561 | 추가: | |
| 522 | 562 | #[test] |
| 523 | 563 | fn changed_source_is_reopen_error_before_decode() { |
| 524 | 564 | let s = Scratch::new(); |