{"id":19384330,"url":"https://github.com/wanzenbug/xch","last_synced_at":"2025-04-23T21:32:10.053Z","repository":{"id":57672482,"uuid":"102195884","full_name":"WanzenBug/xch","owner":"WanzenBug","description":"Create a small CLI programm to swap file contests atomically","archived":false,"fork":false,"pushed_at":"2019-10-18T19:58:40.000Z","size":43,"stargazers_count":6,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-02T20:22:29.789Z","etag":null,"topics":["cli","filesystem","utility"],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/WanzenBug.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-02T12:44:17.000Z","updated_at":"2025-01-13T03:48:18.000Z","dependencies_parsed_at":"2022-08-31T02:40:41.840Z","dependency_job_id":null,"html_url":"https://github.com/WanzenBug/xch","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WanzenBug%2Fxch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WanzenBug%2Fxch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WanzenBug%2Fxch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WanzenBug%2Fxch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/WanzenBug","download_url":"https://codeload.github.com/WanzenBug/xch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250518053,"owners_count":21443889,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","filesystem","utility"],"created_at":"2024-11-10T09:29:57.551Z","updated_at":"2025-04-23T21:32:09.736Z","avatar_url":"https://github.com/WanzenBug.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# xch\n\nA Rust library and CLI program to exchange the content of paths. If possible, this try\nto change contents atomically.\n\nCurrent release: 1.1.0\n\n***Note**: Currently only supports atomic exchange on Windows or on Linux using nightly rust*\n\n## CLI\n\nThe program `xch` can be used to e**XCH**ange the content of two paths. \n\n### Install\n`cargo install xch`\n\n### Usage\n```\nUSAGE:\n    xch [FLAGS] \u003cPATH1\u003e \u003cPATH2\u003e\n\nFLAGS:\n    -h, --help          Prints help information\n    -n, --non-atomic    Use non atomic exchange if atomic is not available\n    -V, --version       Prints version information\n\nARGS:\n    \u003cPATH1\u003e    One path to exchange\n    \u003cPATH2\u003e    The other path to exchange\n\n```\n\nAfter the program call, `first/path` will point to the previous content of `second/path` and vice versa. \nThis not only works for files but also for directories or one file and a directory.\n\nBy default all changes are made atomically, you can never observe one change without the other (e.g. \nif `first/path` points to the old content of `second/path`, `second/path` also points to the\nold content of `first/path`). This only works on Windows and Linux.\n\nOn other platforms such as any BSD or MacOS, you always need to specify\n`--non-atomic` to get results.\n\n| platform | atomic xch         | non-atomic xch     | \n|----------|--------------------|--------------------|\n| windows  | :heavy_check_mark: | :heavy_check_mark: |\n| linux    | :heavy_check_mark: | :heavy_check_mark: |\n| others   | :x:                | :heavy_check_mark: |\n\n## Crate\n\nThe functionality is also available as a crate. Add `xch = \"1.1.0\"` to your `Cargo.toml`.\nThen you need to import the crate to your code\n```Rust\nuse libxch;\n```\nThen you can start exchanging the content of files\n```Rust\nif let Err(e) = libxch::xch(\"file1\", \"path/to/file2\") {\n    // Error handling here\n}\n```\nThis is is the equivalent of running `xch` in default mode, i.e. it only works on Windows and Linux.\nuse `libxch::xch_non_atomic(\"file1\", \"path/to/file2\")` to get a portable, but non-atomic exchange.\n\n[Documentation](https://docs.rs/xch)\n\n## License\n\nLicensed under [MIT license](./LICENSE)\n\n## Future\n\nHere are some missing features that will hopefully be added in the future:\n- MacOS atomic exchange using the `ExchangeData` syscall.\n- Better error messages\n- More options.\n\n#### Please feel free to open an issue if you have a specific request\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwanzenbug%2Fxch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwanzenbug%2Fxch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwanzenbug%2Fxch/lists"}