memory addresses

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
com1
Member
Member
Posts: 105
Joined: Sat Apr 28, 2007 11:57 am
Location: TN

memory addresses

Post by com1 »

hey,

i wanted to see if these FAT attribute constant addresses are OK.

ATTR_READONLY =0x001
ATTR_SYSTEM =0x20
ATTR_HIDDEN =0x0002
oh microsoft, microsoft, what souls you have dismayed
xsix
Member
Member
Posts: 59
Joined: Tue Oct 24, 2006 10:52 am

Post 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 ?
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Post 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.
User avatar
os64dev
Member
Member
Posts: 553
Joined: Sat Jan 27, 2007 3:21 pm
Location: Best, Netherlands

Post 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 :evil:
end of rant.
Author of COBOS
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Post 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.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Post 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).
Every good solution is obvious once you've found it.
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Post 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.
User avatar
Kevin McGuire
Member
Member
Posts: 843
Joined: Tue Nov 09, 2004 12:00 am
Location: United States
Contact:

Post 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. :P

And... the poster wasted the most time not us! "com1"
Post Reply