Page 1 of 1
memory addresses
Posted: Mon May 21, 2007 7:37 pm
by com1
hey,
i wanted to see if these FAT attribute constant addresses are OK.
ATTR_READONLY =0x001
ATTR_SYSTEM =0x20
ATTR_HIDDEN =0x0002
Posted: Tue May 22, 2007 1:09 pm
by xsix
maybe OKay, maybe not, but why you've ripped the code? or you are really beginner. i just can't see the point of writing 0x000001 instead of 1 or 0x1. tell me WHY ?
Posted: Tue May 22, 2007 2:58 pm
by pcmattman
This is what they should be:
Code: Select all
#define ATTR_READ_ONLY 0x01
#define ATTR_HIDDEN 0x02
#define ATTR_SYSTEM 0x04
#define ATTR_VOLUME_ID 0x08
#define ATTR_DIRECTORY 0x10
#define ATTR_ARCHIVE 0x20
#define ATTR_LONG_NAME ( ATTR_READ_ONLY | ATTR_HIDDEN | ATTR_SYSTEM | ATTR_VOLUME_ID )
#define ATTR_LONG_NAME_MASK ( ATTR_READ_ONLY | ATTR_HIDDEN | ATTR_SYSTEM | ATTR_VOLUME_ID | ATTR_DIRECTORY | ATTR_ARCHIVE )
Have you read the FAT doc from Microsoft? It has everything you need.
Posted: Wed May 23, 2007 12:51 am
by os64dev
xsix wrote:maybe OKay, maybe not, but why you've ripped the code? or you are really beginner. i just can't see the point of writing 0x000001 instead of 1 or 0x1. tell me WHY ?
mayby same reason why i do it.
0x01 - means byte domain (8 bits)
0x0001 - means word domain (16 bits)
0x00000001 - means dword domain (32 bits)
so your point of him being a real beginner is kind of sad, or better really dumb. People develop an own style of programming which is problably not like yours and maybe even better. Damn now i am in a ranting mode. so if you cannot make a useful remark... then DONT
end of rant.
Posted: Wed May 23, 2007 12:58 am
by pcmattman
In the context of FAT filesystems, though, it makes no sense to read/write anything but a byte. The attributes are one byte long, and there's no escaping that.
The other thing is, his values are correct, but extremely messy.
Code: Select all
#define ATTR_READONLY 0x001
#define ATTR_SYSTEM 0x20
#define ATTR_HIDDEN 0x0002
There is no pattern in the definitions, which makes this really hard to understand. The best practice is to use byte length where you need bytes, words when you need words and dwords when you need dwords. It's pointless (and a waste of time) to write in the extra 0s.
Posted: Wed May 23, 2007 1:12 am
by Solar
I'd like to note that, regardless of the number of zeroes, #defines end up being of type int anyway unless you add specifiers (0x01l for long, for example).
Posted: Wed May 23, 2007 1:15 am
by pcmattman
Yes, but the shorter they are the easier they are to read, and aren't mistaken as longer integers.
In the end, it's not our place to tell people how to code. I just don't like seeing people waste time with small things (such as extra 0s).
Then again, this whole argument is wasting time over a small thing.
Posted: Wed May 23, 2007 1:19 am
by Kevin McGuire
I can waste my time like I want to waste it, because...
<ding> <ding> <ding> <ding> <ding> <ding>
It is my time.
And... the poster wasted the most time not us!
"com1"