Jump to content


Get list of files with *.dds


24 replies to this topic

#21 Goz

    Senior Member

  • Members
  • PipPipPipPip
  • 575 posts

Posted 05 May 2009 - 10:37 AM

Phlex said:

1. ok, so I've got the name and file extension, how can I effectively go


LPCSTR caPaths[Directories.size()];

for(int i = 0; i < Directories.size(); i++)
{
caPaths[i] = LPCSTR("Media/LightProbes/" + Directory[i]);
}


??

Firstly you should be using LPSTRs not LPCSTRs as the const will play havoc with you. Secondly you don't seem to have an idea as to how pointers work. You need to allocate the space for the string before you assign to it.

Failing that you could just use the STL string (std::string).

Using that you could re-write that code as


std::string caPaths[Directories.size()];


for(int i = 0; i < Directories.size(); i++)

{

	caPaths[i] = std::string( "Media/LightProbes/" ) + std::string( Directory[i] );

}


This way you are letting C++ do all the work. Microsoft also provides a similar string class called CString. Its available under MFC and ATL. Failnig that I'm sure there are several string classes you could use. I wrote myself one recently for some cross platform fun.

Quote

2. What exactly is an "access violation"? I've seen them so many times but never actually known what they are.

An access violation is an exception raised by the operating system. It informs you that you have tried to access some memory you aren't allowed to access (hence access violation). You can easily recreate them by writing to a NULL pointer, writing to a pointer higher than 0x80000000 (in a standard win32 setup) or, simply, by writing to a block of memory that hasn't been assigned to your process (ie allocated).

Primarily I think you need to do more research into what pointers are and how to use them as this does appear to be quite a large hole in your current knowledge.

#22 AdrianD

    New Member

  • Members
  • PipPip
  • 27 posts
  • LocationHamburg

Posted 05 May 2009 - 10:43 AM

don't forget to call FindClose(Handle) when you finshed searching.

#23 rouncer

    Senior Member

  • Members
  • PipPipPipPip
  • 2725 posts

Posted 05 May 2009 - 04:55 PM

Oh i didnt understand, i thought youy were just writing a file loader, sorry my mistake.

#24 Phlex

    Member

  • Members
  • PipPip
  • 53 posts

Posted 05 May 2009 - 07:53 PM

I quite agree, my knowledge on pointers is rather terrible, thanks for the help everyone, your comments are all taken into consideration.

@Adrian, thanks for the tip :)

@rouncer, no trouble, thanks for helping

#25 Goz

    Senior Member

  • Members
  • PipPipPipPip
  • 575 posts

Posted 05 May 2009 - 09:29 PM

Phlex said:

I quite agree, my knowledge on pointers is rather terrible, thanks for the help everyone, your comments are all taken into consideration.

I'd strongly recommend looking into a bit of assembly (Simply debugging your code using the disasembler is a great way to learn if you are prepared to figure out what is going on in memory and the registers). It will give you a great idea of how memory works.

Addressable memory on a standard win 32 process can be thought of as a HUGE array of 2^31 bytes (or chars). A memory address is just the array index into that array. Its obviously gets a lot more complicated than that because you cannot guarantee exactly where memory will be allocated. However if you allocated a struct that has 4 DWORDs in it you know that there are 4 DWORDS each DWORD is made of 4 bytes. Therefore the allocate takes 16 bytes. The memory address of the structure is the first "index" of the first byte. So to get the 3rd DWORD in the structure you know it is the base index PLUS 12 bytes. The following 4 bytes then make up the DWORD.

Not sure that will help at all .. but well worth spending some serious time playing with pointers :)





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users