Hello fellas, i wanna do something like an cmd file explorer in C++, the scope is to open directoryes and run files, nothing else for now, but i managed to do it but whenever i try to enter to a folder it gets me on other ones, for example: i choose folder 2F from C:\ and it gets into it, after trying to get into another folder or run a file from the "2F" folder it gets me to for example, to Documents and Settings, and i dont know what im doing wrong, please help me!
Thanks in advance!
PS: I know that the code need changes, i'll do them after i fix the main problem.
You have a mix of POSIX file system calls (opendir, readdir, closedir), but expect it to run in a Windows (or DOS) shell. That's a little weird.
Hmm, how do i can fix it then? Also, its better to use WIN32_FIND_DATA FindFileData; HANDLE hFind; ?
Those three letter function names, ... why?
It's a bit easier to be to write it faster and i like it more, i dont wanna make something like void replaceslashesoperation() instead of void rso(), i know what it mean, but also i know it will be harder for others to read the code, this isnt a main problem for now.
"You have a mix of POSIX file system calls (opendir, readdir, closedir), but expect it to run in a Windows (or DOS) shell. That's a little weird."
It is a little weird, but some of us have unix emulation on our win box, allowing for some very strange batch files that invoke unix shell commands and similar oddities in short utility programs that exploit the best of both worlds.
I have a number of these, you get used to it -- I have a send-to batch file in my windows send-to folder for bzip2 (both compress and decompress).
It's a bit easier to be to write it faster and i like it more, i dont wanna make something like void replaceslashesoperation() instead of void rso(), i know what it mean, but also i know it will be harder for others to read the code, this isnt a main problem for now.
I would caution you against this practice. Yeah, you know what it means now, but what about when you put it aside to work on other things, and then get back to it in 18 months? Will rso, cdo and mfo still be meaningful? How much time does it take to type in the couple of calls to replaceSlashes? How much time will it take to figure out what your cryptic code means in the future?
I understand--I started by learning Applesoft where variables were 2-character names and I didn't understand why anybody needed more characters. And you're working on a little utility program that may never need to be upgraded. But it is good to get in the habit of writing maintainable software--your future self will love you for it, especially as your programs get more complex.
Why are you replacing single slashes with double slashes?? I think you may be confusing the need for \\ in a string constant with what's needed in the string.
Line 61: you're assuming that dloc ends with a slash. On the top level call, that might not be true.
Line 63: ssc might be uninitialized
i dont wanna make something like void replaceslashesoperation() instead of void rso()
I understand but with function names like rso() and cdo(), you might as well use xx() and xxx().
i know it will be harder for others to read the code, this isnt a main problem for now.
Yes it is. You're asking others on this forum to read your code now.
@doug4 @dhayden
Oops, i didnt know that shortening may cause such a problem, i'll change it, also, i think i spotted my mistake in the code, i also need to remake the entire program which i will do it now.
Line 63: ssc might be uninitialized
Umm, what? It is and i get no warning/error about that