Conversation
|
Just a quick suggestion |
|
I looked at find first as you suggested, but didn't see how I could 'find' a device without it existing on the filesystem. I admit I didn't actually try it so it might have worked just fine. I ended up just trying to open it readonly and if successful I could use https://fd.lod.bz/rbil/interrup/dos_kernel/214400.html#2860 to determine if it was a device or not. I'll need to test thoroughly... |
|
But how perform_dir() works? |
Yes, I'll modify to use findfirst(). I think what put me off was the thought that it was scanning a directory looking for a match, but if the target is explicit perhaps it does something special. Also I just checked what MS-DOS 6.22 (& OPENDOS 7.01) does with FreeCOM does this |
|
If you removed ':' then |
|
findfirst_f() seems to work and is a lot smaller than my interrupt guff. I couldn't figure out the correct place to return an error if redirecting to a colon suffixed name that isn't an actual device. So what I have now is |
src/command.c
Outdated
| #define _A_DEVICE 0x40u | ||
| #endif | ||
| #ifndef FA_DEVICE | ||
| #define FA_DEVICE 0x40u |
There was a problem hiding this comment.
I thought FA_* were the search attribute and A* were the results. I know they are the same, but just trying to make it look right. Happy to use _A_DEVICE though.
There was a problem hiding this comment.
But it seems you don't need
to use FA_DEVICE in the attr
input. perform_dir() doesn't.
There was a problem hiding this comment.
This is where I don't get how it would work. Do you think I should use 'name' or *.*, and what search attribute 'FA_RDONLY+FA_ARCH+FA_SYSTEM+FA_HIDDEN' doesn't include 0x40? I'm fine with checking the results for _A_DEVICE though.
src/command.c
Outdated
| if (is_device_spec(pipe_file[STDIN_INDEX], &colon)) { | ||
| pipe_file[STDIN_INDEX][colon] = '\0'; | ||
| if (!is_device(pipe_file[STDIN_INDEX])) | ||
| pipe_file[STDIN_INDEX][colon] = ':'; |
There was a problem hiding this comment.
No back-n-forth please.
Check first, change next.
There was a problem hiding this comment.
Check first, change next.
Oh yes, I agree it looks horrid. But otherwise I have to duplicate the string e.g.
if (is_device_spec(pipe_file[STDIN_INDEX], &colon)) {
char *s = strdup(pipe_file[STDIN_INDEX]);
if (s) {
s[colon] = '\0';
if (is_device(s)
pipe_file[STDIN_INDEX][colon] = '\0';
free(s);
}
}You prefer this?
There was a problem hiding this comment.
Why do you even need 2
functions? Add is_coloned_device()
and check for colon, then for device.
It can return multiple (3) values to
identify the actual situation, and it
probably can remove the colon if
device exists..
|
I personally wouldn't write |
I don't like it either, but where in the code should I provoke an error? |
You simply need to move |
If output is redirected to name with a colon suffix, test if the unsuffixed name exists as a device and use that, or error.
So this trims a trailing colon from file names that may be a device, BUT I don't like that if you pass it a
name + :that isn't a device it has the potential to overwrite some other file.e.g.
Short of doing 'is_device_name()' on the filename, I don't know how to make this safe?