News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

filecopy

Started by felipe, February 25, 2019, 04:59:43 AM

Previous topic - Next topic

aw27

Quote from: jj2007 on March 01, 2019, 06:35:35 PM
Where is it documented that a malformed "2"file.txt" should produce a well-formed 2file.txt?
Where is it documented that a malformed "2"file.txt" should produce a 2 file?  :biggrin:
And why filecopy "original file.txt" "2"""""""""""file.txt" produces a 2 file?  :icon_eek:

The expected behaviour should be an error or ignoring the double quote(s) as Microsoft does in copy.exe.

TimoVJL

#16
The program actually owns it's command line format ?
Example to conform MS C++, Parsing C++ Command-Line Arguments
Naming Files, Paths, and Namespaces

EDIT: an interesting shell function PathGetArgsA function.#define WIN32_LEAN_AND_MEAN
#include <windows.h>
//#include <shlwapi.h>

#pragma comment(lib, "msvcrt.lib")
LPCSTR __stdcall PathGetArgsA(LPCSTR pszPath);
#pragma comment(lib, "shlwapi.lib")

void __cdecl mainCRTStartup(void)
{
char d, *p, *p1, *p2, *p3;
p = GetCommandLineA();
p1 = (char*)PathGetArgsA(p);
puts(p);
puts(p1);
p2 = (char*)PathGetArgsA(p1);
*(p2-1) = 0; // user should avoid this
p3 = (char*)PathGetArgsA(p2);
*(p3-1) = 0; // user should avoid this
puts(p1);
puts(p2);
puts(p3);
printf("%p,%p,%p,%p\n", p, p1, p2, p3);
_getch();
ExitProcess(0);
}
May the source be with you

jj2007

Quote from: AW on March 01, 2019, 07:49:08 PMWhere is it documented that a malformed "2"file.txt" should produce a 2 file?  :biggrin:

Nowhere, of course - it's malformed. But you suggested that it should produce 2file.txt:
Quote from: AW on March 01, 2019, 05:00:55 PMI am not going to ask the reason filecopy origfile.txt "2"file.txt" produces a file named 2 when it should have produced a file named 2file.txt

hutch--

I vaguely remember the very old "argv" "argc" notation of long ago that didn't handle names with spaces either, prior to I think it was NT4, there were no file names with spaces as the OS versions would not handle it. Try a file name in the DOS era, "my.file.name with spaces.whatever" and you are in for a less than pleasant surprise.

Attached is a 64 bit scruffy that seems to work OK. NOTE that it uses the hard coded delimiter #

aw27


felipe

Quote from: AW on March 01, 2019, 05:00:55 PM
The OP is expected to be aware of the limitations and not ask users to check if something works or not when they can do it themselves or should have done it themselves beforehand.
I knew that this was never an error-free program from the beginning... :idea: Since we are talking about "standards" here,  i have one for you:
when i reply to your first question with this:
Quote from: felipe on March 01, 2019, 03:52:43 AM
it doesn't work?  :idea:
i was expecting that my answer wasn't so difficult to you to understand.  ::)
Of course your "standard" (and maybe jj'"standard" as well) has been somenthing like: let's ignore simple reallity, lets use this "case" to stretch the programming horizonts of the world, yeah, lets be better programmers...  :icon14:


felipe

Quote from: TimoVJL on March 01, 2019, 08:14:17 PM
The program actually owns it's command line format ?
Yes timovjl, that was the idea from the beginning, thanks for understand that.  :t
But i repeat for those that didn't get it: the program never intended to be an error free program. It was just an excercise.  :idea:
I agree with the discussions about good programming practices and all that, what i dislike is to take over my shoulders the way others abuse of my good intentions of collaborate with the forum, like if i was working for them or something like that... :eusa_naughty:
Why they should treat me like an example of bad practices? can't just they talk about the program, maybe using brain abstraction capabilities...?  :idea:

hutch--

I still don't understand why the criticism for what is effectively a test piece, what it is was was  explained in the first post and with some explanation that it was not a perfect program. Most people post bits and pieces in here without the expectation that they are perfect things, I wonder why it is happening here.

With a test piece there is little reason to make it idiot proof, the quality of idiot is so high that you can never succeed, best you can do is document the behaviour of the code and call alternative attempts at using it the same as Microsoft do with API functions, the results are UNDEFINED.  :P

guga

Quote from: hutch-- on March 02, 2019, 04:15:09 AM
I still don't understand why the criticism for what is effectively a test piece, what it is was was  explained in the first post and with some explanation that it was not a perfect program. Most people post bits and pieces in here without the expectation that they are perfect things, I wonder why it is happening here.

Didn´t wanted to put more fire on the discussion, but I share the same thoughts. For me, it was only a small test app. Felipe also make fun in the end " but anyway, who really need it... :P"  So, from what i understood it was a test file. Probably a misunderstanding on the way he answered to AW (And vice-versa).

Felipe/AW, it was clearly a misunderstanding. Come on guys, let´s calm down and take a beer. The bar is open. :greensml: :greensml: :greensml:


:t :t :t
Coding in Assembly requires a mix of:
80% of brain, passion, intuition, creativity
10% of programming skills
10% of alcoholic levels in your blood.

My Code Sites:
http://rosasm.freeforums.org
http://winasm.tripod.com

aw27

There was a program sitting here that after 6 days not a single soul bothered to download.
Apparently, I shouldn't have touched it.

When I asked Felipe what would happen if there were file names with spaces he replied with a question not with an answer as expected. Probably I said something foolish and impossible of happening from his master piece.

When I called his attention that I was expecting a reply he said that for what I pay I don't deserve any better.

I don't understand this victimization.

felipe

Quote from: AW on March 02, 2019, 04:58:26 AM
There was a program sitting here that after 6 days not a single soul bothered to download.
Apparently, I shouldn't have touched it.
Nice openning...  ;) Let's see what else comes with this:  :idea:

Quote from: AW on March 02, 2019, 04:58:26 AM
When I asked Felipe what would happen if there were file names with spaces he replied with a question not with an answer as expected. Probably I said something foolish and impossible of happening from his master piece.
The program was so simple and you have been always so nice, so i decided to answer with a little of sarcasm... :idea:

Quote from: AW on March 02, 2019, 04:58:26 AM
When I called his attention that I was expecting a reply he said that for what I pay I don't deserve any better.
I think it was more like:  :idea:
Quote from: AW on March 01, 2019, 04:06:56 AM
It is your turn to answer my question, not ask me to test your software. :idea:

I haven't ask you to test my software...so:  :idea:
Quote from: AW on March 02, 2019, 04:58:26 AM
I don't understand this victimization.
Me neither... :idea:

felipe

Anyway, it seems like i was a little rude. Maybe it was a bad day. I'm sorry, next time i will try to be more gentle with the questions about programs that i upload.  :idea:

Vortex

Hi felipe,

Everything will go fine for you. I am sure you will have new ideas. Step by step felipe, it's OK.

Vortex

https://stackoverflow.com/questions/291424/canonical-way-to-parse-the-command-line-into-arguments-in-plain-c-windows-api

Why the developers of the shell restricted themselves with the UNICODE version of CommandLineToArgv is a mystery.

Implementation of CommandLineToArgv for Win32 (ANSI and alternative Unicode versions) :

http://alter.org.ua/docs/win/args/

CommandLineToArgvA :

https://github.com/futurist/CommandLineToArgvA


felipe

Thanks vortex, you are very kind, really  :icon14: