NAME File::Unsaved - Check whether file has unsaved modification in an editor VERSION This document describes version 0.03 of File::Unsaved (from Perl distribution File-Unsaved), released on 2014-12-14. SYNOPSIS use File::Unsaved qw(check_unsaved_file); die "Can't modify foo.txt because it is being opened and modified in an editor" if check_unsaved_file(path => "foo.txt"); DESCRIPTION FUNCTIONS check_unsaved_file(%args) -> any Check whether file has unsaved modification in an editor. This function tries, using some heuristics, to find out if a file is being opened and has unsaved modification in an editor. Currently the supported editors are: Emacs, joe, vim. Return false if no unsaved data is detected, or else a hash structure. Hash will contain these keys: "editor" (kind of editor). The heuristics are as folow: * Emacs and joe: check whether ".#" symlink exists. Emacs targets the symlink to "@.:" while joe to "@.". Caveat: Unix only. * vim: check whether "..swp" file exists, not older than file, and its 0x03ef-th byte has the value of "U" (which vim uses to mark the file as unsaved). Caveat: vim can be instructed to put swap file somewhere else or not create swap file at all, so in those cases unsaved data will not be detected. Arguments ('*' denotes required arguments): * path* => *str* Return value: (any) SEE ALSO HOMEPAGE Please visit the project's homepage at . SOURCE Source repository is at . BUGS Please report any bugs or feature requests on the bugtracker website When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature. AUTHOR perlancar COPYRIGHT AND LICENSE This software is copyright (c) 2014 by perlancar@cpan.org. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.