Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows improvements #57

Merged
merged 29 commits into from Jan 10, 2022
Merged

Windows improvements #57

merged 29 commits into from Jan 10, 2022

Conversation

daewok
Copy link
Collaborator

@daewok daewok commented Jan 2, 2022

This set of commits implements most of the missing high-level functionality on Windows. The only thing remaining unsupported is user-info. Because of that, I also removed the split between osicat.lisp and osicat-basic.lisp (sorry for the diff noise that creates!).

Much of the missing functionality required calling out to win32 APIs. Additionally, added a few useful win32 defcfuns that aren't used by the high level functionality, but are useful and mirror some of the POSIX defcfuns that also aren't used by the high level API. Between the osicat and osicat-windows packages, I'm now able to use cl-tar to create a tar file from a directory on Windows and even preserve things like sym and hard links!

The only intentional non-Windows behavioral change is in make-link. It originally changed the working directory to *d-p-d*, but that seemed bogus to me for several reasons. First, the current directory is a per-process resource, so it could lead to weird behavior in multi-threaded programs. Second, some implementations have #p"" as the default *d-p-d*. So I instead called merge-pathnames explicitly instead of relying on the working directory.

Some future directions for improvement:

  1. Add a gray-stream that uses win32 APIs to read/write using file handles. With that it's then possible to improve the temporary file support so that it's deleted automatically when closed.
  2. Shift more of the high-level functions to use win32 functions under the hood. Not strictly necessary, but might be more robust and give us more control to make things look more POSIXy where Windows' POSIX implementation falls flat.
  3. Automatic error class creation. I didn't even attempt this given that win32 has an insane number of error codes.

daewok and others added 29 commits January 2, 2022 13:47
There is no setenv, nor unsetenv, but we can emulate both of them using putenv.
It signaled a non-existent condition type
First, look at TMP instead of TMPDIR on Windows.

Second, it's not possible to unlink a file if someone has it open, unless you
use CreateFileA/W and set FILE_SHARE_DELETE. Therefore, note that
OPEN-TEMPORARY-FILE may return a pathname as a second value. If it does, the
user is reponsible to delete that file.

Third, modify WITH-TEMPORARY-FILE to unlink the file.
Involves some slight modifications of tests and completely disabling some
tests.
Addittionally, mark all functions that depend on that as supported
It's present, just not always useful
On non-Windows platforms there is no need to change the current directory; we
can just merge with *D-P-D* and absolutize.

Additionally, specify that the target is merged with the link's
directory. Otherwise, it's possible to inherit the name or type from link if it
is unspecified in target, which is probably not what anyone wants.
Now that most things are implemented on windows as well, there's no need to
keep separate files for the high-level interface.
@luismbo luismbo merged commit a743477 into osicat:master Jan 10, 2022
@luismbo
Copy link
Contributor

luismbo commented Jan 10, 2022

@daewok merged, thanks! I've given you the commit bit, BTW. Feel free to push directly in the future, or to continue to send pull requests if you'd like a code review.

Improvement ideas 1 and 2 seem very good, I agree. BTW, do you know about https://github.com/Lovesan/doors? There might be some intersection here.

@daewok
Copy link
Collaborator Author

daewok commented Jan 11, 2022

That's awesome, thanks!

I did not know about doors (but love the name). If I keep digging into Windows stuff I'll definitely take a look at it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants