Compare commits

...

3 Commits

25 changed files with 61 additions and 41 deletions

View File

@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2021 Lynnesbian
# SPDX-FileCopyrightText: 2021-2022 Lynnesbian
# SPDX-License-Identifier: CC0-1.0
---

3
.gitattributes vendored
View File

@ -1 +1,4 @@
# SPDX-FileCopyrightText: 2021-2022 Lynnesbian
# SPDX-License-Identifier: CC0-1.0
doc/screenshot.png filter=lfs diff=lfs merge=lfs -text

2
.gitignore vendored
View File

@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2021 Lynnesbian
# SPDX-FileCopyrightText: 2021-2022 Lynnesbian
# SPDX-License-Identifier: CC0-1.0
/target

View File

@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2021 Lynnesbian
# SPDX-FileCopyrightText: 2021-2022 Lynnesbian
# SPDX-License-Identifier: CC0-1.0
image: "rust:latest"

View File

@ -3,7 +3,7 @@ Upstream-Name: fif
Upstream-Contact: Lynnesbian <lynne@bune.city>
Source: https://gitlab.com/Lynnesbian/fif/
Files: .idea/**/* .idea/* Cargo.lock .mailmap .kateproject
Files: .idea/**/* .idea/* Cargo.lock .mailmap .kateproject *.toml
Copyright: Lynnesbian
License: CC0-1.0

View File

@ -7,6 +7,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
## Unreleased
### Added
- When using the [`infer`] backend, fif is now able to detect [Mach-O](https://en.wikipedia.org/wiki/Mach-O) binaries
### Other
- (@hannesbraun) Updated [`infer`] to v0.6.0 (!2)
## v0.5.0 - 2022-01-01
### Changed
@ -79,6 +81,7 @@ this version of `clap`, which caused the build to fail. Also, `clap` 3 beta 4 de
- `-I`/`--ignore-unknown-exts` flag for ignoring files with unknown extensions - for example, if fif doesn't know
what a ".fake" file is, setting this flag will prevent it from renaming "photo.fake" to "photo.jpg". This is useful
for avoiding the case where fif incorrectly mislabels an obscure format it isn't aware of as something else.
- (@herbygillot) Added [MacPorts](https://www.macports.org/) install instructions (!1)
### Other
- Refactored `formats.rs`
- More accurate dependency versions in `Cargo.toml` to ensure that the MSRV stays supported

20
Cargo.lock generated
View File

@ -211,9 +211,9 @@ checksum = "de853764b47027c2e862a995c34978ffa63c1501f2e15f987ba11bd4f9bba193"
[[package]]
name = "fastrand"
version = "1.6.0"
version = "1.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "779d043b6a0b90cc4c0ed7ee380a6504394cee7efd7db050e3774eee387324b2"
checksum = "c3fcf0cee53519c866c09b5de1f6c56ff9d647101f81c1964fa632e148896cdf"
dependencies = [
"instant",
]
@ -579,9 +579,9 @@ dependencies = [
[[package]]
name = "quote"
version = "1.0.14"
version = "1.0.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "47aa80447ce4daf1717500037052af176af5d38cc3e571d9ec1c7353fc10c87d"
checksum = "864d3e96a899863136fc6e99f3d7cae289dafe43bf2c5ac19b70df7210c0a145"
dependencies = [
"proc-macro2",
]
@ -723,18 +723,18 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
[[package]]
name = "serde"
version = "1.0.133"
version = "1.0.134"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97565067517b60e2d1ea8b268e59ce036de907ac523ad83a0475da04e818989a"
checksum = "96b3c34c1690edf8174f5b289a336ab03f568a4460d8c6df75f2f3a692b3bc6a"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.133"
version = "1.0.134"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed201699328568d8d08208fdd080e3ff594e6c422e438b6705905da01005d537"
checksum = "784ed1fbfa13fe191077537b0d70ec8ad1e903cfe04831da608aa36457cb653d"
dependencies = [
"proc-macro2",
"quote",
@ -743,9 +743,9 @@ dependencies = [
[[package]]
name = "serde_json"
version = "1.0.75"
version = "1.0.76"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c059c05b48c5c0067d4b4b2b4f0732dd65feb52daf7e0ea09cd87e7dadc1af79"
checksum = "edde269018d33d7146dd074e5f7da6fef9b0a957507454c867caa0852c560a9a"
dependencies = [
"itoa",
"ryu",

View File

@ -1,6 +1,3 @@
# SPDX-FileCopyrightText: 2021 Lynnesbian
# SPDX-License-Identifier: CC0-1.0
[package]
name = "fif"
description = "A command-line tool for detecting and optionally correcting files with incorrect extensions."

View File

@ -1,5 +1,2 @@
# SPDX-FileCopyrightText: 2021 Lynnesbian
# SPDX-License-Identifier: CC0-1.0
[build.env]
passthrough = ["RUST_BACKTRACE", "RUST_LOG", "FIF_LOG"]

View File

@ -140,6 +140,25 @@ You can also manually specify an output format to use:
fif -O powershell ~/Documents > output.ps1
```
#### The `--fix` flag
If, however, you'd rather have fif fix the misnamed files itself, rather than relying on a shell script, you can use
the `--fix` flag:
```bash
# rename any misnamed .jpg files in the user's pictures directory
fif ~/Pictures --fix -e jpg
# fix any misnamed files found in the user's downloads
fif ~/Downloads --fix
```
By default, fif will avoid taking any potentially destructive actions (renaming a file to a name that already exists).
This behaviour can be disabled with the `--overwrite` flag, which will instead prompt you to overwrite the existing
file. fif will also prompt you to retry on errors.
For more information on how the `--fix` flag works, and how it behaves in conjunction with the `--overwrite` flag
and `--prompt` parameter, see [the corresponding wiki page](https://gitlab.com/Lynnesbian/fif/-/wikis/Fix).
### Logging
By default, fif will log any info, warnings, and errors encountered during execution. This can be changed with the `-v`
flag:

View File

@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2021 Lynnesbian
// SPDX-FileCopyrightText: 2021-2022 Lynnesbian
// SPDX-License-Identifier: LGPL-3.0-or-later
use std::process::Command;

View File

@ -1,6 +1,6 @@
#!/bin/bash
# SPDX-FileCopyrightText: 2021 Lynnesbian
# SPDX-FileCopyrightText: 2021-2022 Lynnesbian
# SPDX-License-Identifier: CC0-1.0
set -e

View File

@ -1,6 +1,3 @@
# SPDX-FileCopyrightText: 2021 Lynnesbian
# SPDX-License-Identifier: CC0-1.0
# avoid-breaking-exported-api = false # only available on nightly for now
cognitive-complexity-threshold = 15
msrv = "1.54.0"

8
doc/README.md Normal file
View File

@ -0,0 +1,8 @@
Where's the documentation?
===
If you're looking for documentation on fif, try checking...
- The built-in help documentation, by running `fif --help`
- [The usage section in the README file](https://gitlab.com/Lynnesbian/fif/-/blob/master/README.md#usage), for a
brief overview of fif's functionality and how to use it
- [The wiki](https://gitlab.com/Lynnesbian/fif/-/wikis/home), for more detailed information on fif's behaviour
- [Docs.rs](https://docs.rs/fif/latest/fif/), for information pertaining to fif's internals

View File

@ -1,6 +1,3 @@
# SPDX-FileCopyrightText: 2021 Lynnesbian
# SPDX-License-Identifier: CC0-1.0
max_width = 120
fn_single_line = true
hard_tabs = true

View File

@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2021 Lynnesbian
// SPDX-FileCopyrightText: 2021-2022 Lynnesbian
// SPDX-License-Identifier: LGPL-3.0-or-later
//! File handling - scanning, detecting MIME types, and so on.

View File

@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2021 Lynnesbian
// SPDX-FileCopyrightText: 2021-2022 Lynnesbian
// SPDX-License-Identifier: LGPL-3.0-or-later
//! The [`Findings`] and [`ScanError`] structs, used for conveying whether a given file was able to be scanned, whether

View File

@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2021 Lynnesbian
// SPDX-FileCopyrightText: 2021-2022 Lynnesbian
// SPDX-License-Identifier: LGPL-3.0-or-later
//! Logic for handling the various output formats that fif can output to.

View File

@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2021 Lynnesbian
// SPDX-FileCopyrightText: 2021-2022 Lynnesbian
// SPDX-License-Identifier: LGPL-3.0-or-later
//! This library consists of all of the things fif needs to run. It only exists as a library to separate code, and to

View File

@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2021 Lynnesbian
// SPDX-FileCopyrightText: 2021-2022 Lynnesbian
// SPDX-License-Identifier: LGPL-3.0-or-later
// fif - a command-line tool for detecting and optionally correcting files with incorrect extensions.

View File

@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2021 Lynnesbian
// SPDX-FileCopyrightText: 2021-2022 Lynnesbian
// SPDX-License-Identifier: LGPL-3.0-or-later
//! Backend-neutral Mime database abstraction.

View File

@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2021 Lynnesbian
// SPDX-FileCopyrightText: 2021-2022 Lynnesbian
// SPDX-License-Identifier: LGPL-3.0-or-later
//! Command line argument parsing logic and associated functions.
@ -58,8 +58,8 @@ pub enum Prompt {
long_version = CLAP_LONG_VERSION.as_str(),
author = option_env!("CARGO_PKG_AUTHORS").unwrap_or("Lynnesbian"),
about = option_env!("CARGO_PKG_DESCRIPTION").unwrap_or("File Info Fixer"),
before_help = "Copyright © 2021 Lynnesbian under the GPL3 (or later) License.",
after_long_help = "Copyright © 2021 Lynnesbian\n\
before_help = "Copyright © 2021-2022 Lynnesbian under the GPL3 (or later) License.",
after_long_help = "Copyright © 2021-2022 Lynnesbian\n\
This program is free software: you can redistribute it and/or modify \
it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 \
of the License, or (at your option) any later version.",

View File

@ -1,5 +1,4 @@
// SPDX-FileCopyrightText: 2021 2021 Lynnesbian
// SPDX-FileCopyrightText: 2021 Lynnesbian
// SPDX-FileCopyrightText: 2021-2022 Lynnesbian
// SPDX-License-Identifier: LGPL-3.0-or-later
use std::collections::{BTreeMap, HashMap};

View File

@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2021 Lynnesbian
// SPDX-FileCopyrightText: 2021-2022 Lynnesbian
// SPDX-License-Identifier: LGPL-3.0-or-later
//! Various minor utilities.

View File

@ -1,6 +1,6 @@
#!/usr/bin/env python
# SPDX-FileCopyrightText: 2021 Lynnesbian
# SPDX-FileCopyrightText: 2021-2022 Lynnesbian
#
# SPDX-License-Identifier: LGPL-3.0-or-later