jaepi 22 Practically a Master Poster

Hello there, any idea what function in the standard library corresponds to these win32 apis (GetPrivateProfileInt and GetPrivateProfileString). Thanks. :)

jaepi 22 Practically a Master Poster

Hello there, I have here a bit of confusion with fread. I have here a .cue file generated in windows. I tried to read through the entire file in windows and when I printed the buffer, it gives me the correct content of the file, but when I read it in linux, it skips one letter. Any ideas why? Thanks. :)

jaepi 22 Practically a Master Poster

Hello, there. I just would like to ask any other possible ways to read wchar_t data in a file? I tried to use ifstream but it seems that the '>>' operator cannot be used to unsigned short variables with the likes of wchar_t. Thanks. :)

jaepi 22 Practically a Master Poster

In addition, does the fread() function can use wchar_t* type as buffer?

jaepi 22 Practically a Master Poster

Hello there. Is there anyway that you can convert the '\n' in windows which is 2bytes to the '\n' 1byte so that the linux could read it?

jaepi 22 Practically a Master Poster

Thanks sirs.

jaepi 22 Practically a Master Poster

I would just like to clarify, I should define _LARGEFILE_SOURCE and _LARGEFILE64_SOURCE to the .cpp files where I use fread and fwrite?

jaepi 22 Practically a Master Poster

I've already included it in my compiler options, still it gives me the error "fread64 was not declared in this scope". T_T

jaepi 22 Practically a Master Poster

>For the record: There is no such thing as VC++, you're coding C++ in Visual Studio.

VC++ - Visual C++, in short VC++. If that is what he means.

jaepi 22 Practically a Master Poster

I was wondering why the windows compiler (specifically win32) tolerated such kind of error. It'll surely work. Thanks!

jaepi 22 Practically a Master Poster

Not exactly edit the whole fread and fwrite in the standard library. Creating an interface that would correspond to the fread64 and fwrite64 would do. I'm using g++ version 4.0+ compiler, I'm doing it in linux. I think g++ does not support it.

jaepi 22 Practically a Master Poster

I did not actually created it in windows, I used linux.
This might help although this one is in linux.

jaepi 22 Practically a Master Poster

Yep, that is exactly what the code is doing. I'm actually porting a windows code to linux. And I was wondering why did he(windows programmer) did that.

jaepi 22 Practically a Master Poster

Hello there, I'm currently encountering a strange error which is I don't know why or could this one be possible. I have several for loops inside a function and I used the iterator outside the said loop, but I do get this error which is kinda strange.

error: name lookup of 'i' changed for new ISO 'for' scoping
error: using obsolete binding at 'i'

Strange.

jaepi 22 Practically a Master Poster

Thanks. But is there someway that I could edit the fread and fwrite so that it would correspond to fread64 and fwrite64.

jaepi 22 Practically a Master Poster

Yes, I used fopen64 to open the iso image which is 4.3gb, but I used fread and fwrite.

jaepi 22 Practically a Master Poster

I was advised by a friend of mine to use fread64, fwrite64 instead of fread and fwrite. Does this exist? Been looking for it's documentation but I haven't found one.

jaepi 22 Practically a Master Poster

Uhmm, what do you think is the one that corresponds to the lpBytesPerSector parameter of the GetDiskFreeSpace "BOOL WINAPI GetDiskFreeSpace(LPCTSTR lpRootPathName, LPDWORD lpSectorsPerCluster, LPDWORD lpBytesPerSector, LPDWORD lpNumberOfFreeClusters, LPDWORD lpTotalNumberOfClusters);"

function to the members of the struct statvfs

"unsigned long f_bsize;
unsigned long f_frsize;
fsblkcnt_t f_blocks;
fsblkcnt_t f_bfree;
fsblkcnt_t f_bavail;
fsfilcnt_t f_files;
fsfilcnt_t f_ffree;
fsfilcnt_t f_favail;
unsigned long f_fsid;
unsigned long f_flag;
unsigned long f_namemax;
unsigned long f_type;
char f_basetype[FSTYPSZ];
char f_str[FSSTRSZ];" ?

jaepi 22 Practically a Master Poster

I think I might use the statvfs function. I'm kind of confused with the parameters passed in GetDiskFreeSpace (specially the ones that receives the output).

jaepi 22 Practically a Master Poster

I will try to search and implement that. Thanks!

jaepi 22 Practically a Master Poster

Hello there, do you have any idea what is the corresponding function of this Win32 api (GetDiskFreeSpace) in standard library?

Thanks. :)

jaepi 22 Practically a Master Poster

> So what does your CreateFile() look like then?

Since CreateFile can open file, device, disk, blah blah, I directly replaced them in the entire library that I am porting with the corresponding open function in the standard library.

>How does it turn a FILE* into a HANDLE?

This is exactly one of the things that confuses me. I'm not yet that sure of what I did. Let me show you an example.

typedef void* HANDLE;
....
//somewhere in one of my functions
Example_Function(HANDLE* pFile){
  CLinux* lInterface;
  *pFile = NULL;
  FILE* fildes = NULL;
  fpos_t position;

  fildes = fopen64("/home/user/test.iso", "r");
  *pFile = fildes;
  

  lInterface->SetFilePointeEx(*pFile, some_variable, position, FILE_BEGIN);

  //FILE_BEGIN was defined as SEEK_SET
}

I'm sorry if I was not able to give you a desirable answer, but this is what I did. For now, I'm not using the interface that I did, I directly placed or replaced the Win32 apis with it's corresponding standard lib function.

jaepi 22 Practically a Master Poster

> Lemme guess, you opened the file with CreateFile() ?

I'm making a linux interface, I'm porting win32 apis inorder to fit for the linux platform. CreateFile() is replaced with fopen, fopen64 or open.

jaepi 22 Practically a Master Poster

I have typdef it in my header as void* since HANDLE is a void*. I have defined all of the Win32 datatypes that are used by their corresponding types.

jaepi 22 Practically a Master Poster
BOOL CLinux::SetFilePointerEx(HANDLE hFile, LARGE_INTEGER liDistanceToMove, fpos_t lpNewFilePointer, DWORD dwMoveMethod ){
    
if(hFile == NULL){
        cout << "Error SetFilePointerEx, hFile is NULL" << endl;
    }    

fgetpos((FILE*)hFile, &lpNewFilePointer);    
 
    int iCheck = fsetpos((FILE*)hFile, &lpNewFilePointer);
    
    if(iCheck != 0){
        return true;
    }else return false;
}

This is just part of my linux interface which I am currently working on.

jaepi 22 Practically a Master Poster

> They're both standard functions. A hosted compiler is required to provide them.

I mean when you use it in the code? I tried both (using fsetpos without fgetpos and using the former with the latter).

jaepi 22 Practically a Master Poster

> hi please help me....can you give me a code for queue program???

Lol. Very funny.

jaepi 22 Practically a Master Poster

I'd rather use fsetpos. Uhmmm, btw, fgetpos and fsetpos come together, right? Or fsetpos may exist without fgetpos (vice-versa).

jaepi 22 Practically a Master Poster

@Narue - I have heared 'bout fsetpos but I did'nt know that it could deal with larger filetypes. I thought fsetpos64 is used. Thanks! I'll try this instead. Uhmm...have you ever encounter or use fseek64? Which is more preferable between fseek64 and fsetpos?

@vishesh - It says here that fseek64 and even fsetpos64 are new library interfaces? Do have any idea if gcc version 4.0+ supports these functions? Thanks, it really helped me, I'm keeping this document for future references.

@vijayan121 - This is exactly what I need. Thanks!

@all - Thank you very much. :)

jaepi 22 Practically a Master Poster

In addition, what function which is similar to stat that asks for a FILE* fildes rather than int fildes? Thanks!

jaepi 22 Practically a Master Poster

Hello there, do you have any idea where to get a good reference for the function fseek64?
Or does anyone of you here knows this function or is there really a fseek64 function? lol. Thanks!

jaepi 22 Practically a Master Poster

@AncientDragon - My purpose of rewritting some of the win32 apis is that I'm using it for version changes. So I don't have to scan the entire code for these apis or change their parameter types just to make them fit in the standard library. Yeah, I agree, it's really a waste of effort and time, but in my situation, I might have the advantage or I could even use it for future projects. Porting issues are really hard to deal with. Oh well. Hey, thanks for the enlightenment. If this interface will not work, I'll try to, just replace them instead of burning my brain trying to figure out how to rewrite. :)

@vijayan121 - And someone here in the forums would just copy-paste and give it a try. Or maybe I could try it if I'm really out of options. :) . Thanks man.

jaepi 22 Practically a Master Poster

@AncientDragon - GetFileAttributes, GetDiskFreeSpace, ReadFile, WriteFile, SetFilePointer, SetFilePointerEx...and so on...I only lack the first two functions. I'm still working on the next two functions (ReadFile and WriteFile).

@vijayan121 - I'm not that desperate yet. I do have some solutions (like converting wchar_t* to char* using the wcstombs before passing it to the standard lib functions) but I think it's not that effective.

@all - Thank you! :)

jaepi 22 Practically a Master Poster

It's compiled in UNICODE, I've been having a hard time porting these win32 apis to standard library. *sigh*. I'm actually making my own interface so that it would be easy for me to debug and modify.

jaepi 22 Practically a Master Poster

I'm actually converting win32 api to standard library. Win32 api's are using wchar_t* which is hard for me since most of the standard library are using const char* or char*.

jaepi 22 Practically a Master Poster

Hello there, I would just like ask what to use if you want to know if a variable is of type wchar_t* or char* using it in a flow control statement.

Would this work?

void Check(void* pVarToCheck){
    if(sizeof(pVarToCheck) == sizeof(wchar_t))){
        cout << "Variable is wchar_t*" << endl;
   }else if(sizeof(pVarToCheck) == sizeof(char)){
        cout << "Variable is char*" << endl;
   }else cout << "Mofo!" << endl;
}

Thanks!

jaepi 22 Practically a Master Poster

Thank you sirs! :)

jaepi 22 Practically a Master Poster

Uhmmm. What if I will use wcstombs() function to convert wide char to multibyte? Could it be possible?

jaepi 22 Practically a Master Poster

I actually found an open source that corresponds to the functions that I mentioned.

here's the link: http://www.matteolucarelli.net/libreria/GetPrivateProfile/GetPrivateProfile.c.htm

Now my problem is, I need to insert wchar_t* instead of the char* datatypes for the parameters. This version of the function is using standard lib functions which only accepts the datatype char*. Any suggestion on how to or what to do?

jaepi 22 Practically a Master Poster

Do you have any idea what functions to use in standard library to replace these Win32 functions (GetPrivateProfileInt and GetPrivateProfileString)?

Thanks! :)

jaepi 22 Practically a Master Poster

I found out that I have to include the -pthread option into my makefile flags. :)

jaepi 22 Practically a Master Poster

Hello there. What is usually the reason of getting an undefined reference error?

I have already included the pthread.h header file yet I'm still getting the undefined reference error for the pthread_create() function. *sigh*. I'm using makefile in compiling my code. Is there someone here who could enlighten me? Thanks! :)

jaepi 22 Practically a Master Poster

Hello there, I've been messing around with threads these days. Currently, I'm having problems with one of my variables of type pthread_cond_t (let's call it variable Z). I made a class (let's say class X) , and you guessed it right, Z was declared in it with private access level. Now the problem here is the initialization of Z. I initialized it with this value - PTHREAD_COND_INITIALIZER. It produces this error - error: expected primary-expression before '{' token.

This is the way I initialized it.

//constructor
X::X(): Z(PTHREAD_COND_INITIALIZER)
{
  //code here
}

What do you think is the problem?

Thanks! :)

jaepi 22 Practically a Master Poster

Hello, there. I'm having trouble with the initialization of variable of type sem_t.

I used this.

sem_t example;

example = NULL;

if(example == NULL){
    /* code here */
}

I'm getting the error, "no match for operator ==".

What value do you think I should place in the initialization?

I tried 0, but still the same.

Thanks.

jaepi 22 Practically a Master Poster

I placed #pragma once in file X and it worked. Thanks guys. :)

jaepi 22 Practically a Master Poster

Hello there, I have here a problem with the compilation of my program. The compiler tells me that my typedefs are redefined, but I defined it only once. Ok, heres the score, I have here a header file (let's name this as file X) that contains all the typedefs that I need (so that I will be able to reuse it to other files). I have included it to the two files (let's say, file A and file B) that really needs it badly and these two files (file A and B) are included to a file that needs them too (let's call this one as file C). Whenever I compile file C, I get the error of redefinition. Is there something wrong with the way I mess with the files? I'm using gcc thus involving Makefile.

Thanks! :)

jaepi 22 Practically a Master Poster

Hello there, I have a problem that's been bugging me. I scanned my pc using my Semantec anti virus by right clicking on the drive and simply choose the scan for viruses option. To my surprise, the usual scan status window ( that window that shows up the time, items and the files scanned - I don't know the exact name of that window) is not showing up or it did not popped. I did'nt touch any of it's configuration. I always do the scanning routine once a week. This is the first time that happened. I'm kinda paranaoid right now, please, can someone here explain to me what is the problem with my anti virus. Thanks.

jaepi 22 Practically a Master Poster

Thanks a lot. :)

jaepi 22 Practically a Master Poster

In addition the CreateEvent() function. :)

jaepi 22 Practically a Master Poster

Hello there, do you have any idea of what is the corresponding standard lib function of Win32's WideCharToMultiByte()? Thanks!