|
My question is somewhat religious and definitely mundane compared to the guy who wants to write an OS in .net, but I live in the world of maintenance code. My bugaboo is consistency. Take a project of veteran developers (they each have their own style) add a few whiz kids (who have their own styles), add code standards that are pretty much ignored, and shake. The results can be mind-boggling. I've seen coding conventions deal with many issues, but I don't think I've seen one dealing with filenames and their construction. In the project I am re-factoring now, the file system is fixed. The primary folders in the root are fixed, so we have something like:
\root
application
backup
archives
I have a lot of code that builds file specifications including folder names. A great deal of concatenation, removing slashes, adding slashes and what not, it just begs for errors. So instead of something like this:
#define ROOT_FOLDER L"\\root"
#define APP_FOLDER L"application"
#define BACKUP_FOLDER L"backup"
#define ARCHIVE_FOLDER L"archives"
and then constructing complete file specs, I re-factored to something like this:
#define ROOT_FOLDER L"\\root"
#define APP_FOLDER L"\\root\\application"
#define BACKUP_FOLDER L"\\root\\backup"
#define ARCHIVE_FOLDER L"\\root\\archives"
and deleted as much string formatting code that I could. Then I got to thinking, maybe there should be a trailing slash as well - which led me here to ask how others like to do this...
Thoughts?
Charlie Gilley
<italic>Stuck in a dysfunctional matrix from which I must escape...
"Where liberty dwells, there is my country." B. Franklin, 1783
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
|
|
|
|
|
charlieg wrote: I live in the world of maintenance code. We will have you in our prayers.
Ravings en masse^ |
---|
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "If you are searching for perfection in others, then you seek disappointment. If you are seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010 |
|
|
|
|
|
Nah, it comes with its own set of challenges. Besides, I can always blame the original developers.
Charlie Gilley
<italic>Stuck in a dysfunctional matrix from which I must escape...
"Where liberty dwells, there is my country." B. Franklin, 1783
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
|
|
|
|
|
Path.Combine() automatically handles doubled up or missing backslashes so I don't worry about it.
- I would love to change the world, but they won’t give me the source code.
|
|
|
|
|
that looks like C, not C#
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
My thoughts exactly
I'm not sure if that's available in C, but it shouldn't be hard to write
|
|
|
|
|
I'm so used to Path.Combine, that if I had to go to a system without it, I'd probably have to roll my own - it's just too useful!
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
It's actually C++ code, but what amazes me is the lack of writing something like PathCombine. Yes, I have a new project.
Charlie Gilley
<italic>Stuck in a dysfunctional matrix from which I must escape...
"Where liberty dwells, there is my country." B. Franklin, 1783
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
|
|
|
|
|
This may help: Reference Source: Path.Combine[^]
And when you get it working, stick it up as an article / tip for others to enjoy!
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
As long as I've been on this site, you have a point.
Charlie Gilley
<italic>Stuck in a dysfunctional matrix from which I must escape...
"Where liberty dwells, there is my country." B. Franklin, 1783
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
|
|
|
|
|
i prefer trailing slashes at the end of directory names. That way you can distinguish them programmatically and visually from filenames
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
BURN THE W... Oh wait, that actually makes a lot of sense
|
|
|
|
|
come over to the dark side. we have cookies.
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
Come over to the Light Side: we have , and Pizza.
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
i don't drink and my pizza has to be gay.
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
honey the monster, codewitch wrote: my pizza has to be gay.
That's easy: just put ham and pineapple on it.
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Comment begged by your post:
honey the monster, codewitch wrote: pizza has to be gay. Pineapple topping?
Ravings en masse^ |
---|
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "If you are searching for perfection in others, then you seek disappointment. If you are seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010 |
|
|
|
|
|
absolutely.
Although a cowboy with white sauce also counts.
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
stop hijacking my thread
Charlie Gilley
<italic>Stuck in a dysfunctional matrix from which I must escape...
"Where liberty dwells, there is my country." B. Franklin, 1783
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
|
|
|
|
|
slashes go at the end of directories. There you go. =D
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
Over the years I have learned not to care. I have seen and done both so when I start building paths I use PathAddBackslash because it adds one only if necessary. This way the code can accommodate both options.
Lately, I use no leading slashes and I have trailing slashes on directories. Plane, old file names never have them.
"They have a consciousness, they have a life, they have a soul! Damn you! Let the rabbits wear glasses! Save our brothers! Can I get an amen?"
|
|
|
|
|
In DOS, I prefer trailing backslashes on directory paths.
I have begun to try getting into the habit of specifying them on the command line to avoid a certain class of error to which I have proven prone time and time again.
Remember, also, that a _real_ Operating System has a better file specification system:
nodename::devicename:[directoryname.directoryname]filename.extension
|
|
|
|
|
PIEBALDconsult wrote: nodename::devicename:[directoryname.directoryname]filename.extension;version
But I never wave bye bye
|
|
|
|
|
Poop! I'm rusty.
Muchas gracias.
|
|
|
|
|
lol, I actually know what that means.
Zero blue screens. The only time the OS *ever* went down was due to two causes. Driver development, but we all knew to stay away. And, shutting down your workstation then realizing you just shutdown the cluster (and 5000 people would be calling soon).
Charlie Gilley
<italic>Stuck in a dysfunctional matrix from which I must escape...
"Where liberty dwells, there is my country." B. Franklin, 1783
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
|
|
|
|