-
-
Notifications
You must be signed in to change notification settings - Fork 236
Use unique names for temporary files #497
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
Conversation
It also does not change parts which generate randomly-named directories inside |
Error: cannot read file test/1-staticLib-simple/aFcake-dub_test_root.d What's that? |
pattern[prefix.length .. $-1] = name[]; | ||
pattern[$-1] = '\0'; | ||
|
||
auto handle = mkstemps(pattern.ptr, to!int(name.length + 1)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does that work on Windows?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No of course. I have never written a single program for Windows and will need to do some research on WinAPI to figure out the alternative.
Ok, after some investigation of online docs have added Windows version. Can't test it locally though so will rely on tester :( |
Oh, there is no Windows slave in dub travis job? |
Well, it is green now but I really need someone with Windows machine to verify it works there too - I don't have much trust in my blind coding for other platforms. |
|
||
auto dir = getTempDir().toStringz(); | ||
auto name = prefix.toStringz(); | ||
char[MAX_PATH] output; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
= void
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
Windows error
|
@MartinNowak thanks, fixed ones in the paste. |
Partial fix to #482
Will this allow us to get your Jenkins running for the upcoming release? |
I hope so. It seemed to work apart from failing parallel jobs but hard to foresee what will go wrong when more projects get added ;) |
Use unique names for temporary files
After all the trouble with GetTempFileNameW and toUTF16z, I get something like this. So I just generated a UUID based name instead. |
else version (Windows) | ||
{ | ||
import core.sys.windows.windows : MAX_PATH; | ||
import std.string : toStringz, fromStringz; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spaces!
Ouch, I didn't realize this WinAPI function is that useless.
I can see why, considering how incompatible different OS primitives seem to be. |
But it does guarantee uniqueness, until we append the extension. |
Uniqueness alone is not enough to make it useful - with posix function manual appending is not even needed because it is flexible with filename template. Simply having a random filename you can't control is not much better than existing |
Partial implementation to #482 (does not add cache locks)
It currently includes only posix implementation - I need some hints to know how it should be done on Windows correctly.