PDA

View Full Version : File Handling?




trey5498
Jun 18, 2008, 07:19 AM
It seems that now-a-days Google is not what it once was with all the mucked up searches. I am in need of advice as I am a noob of sorts with Mac development. I am designing a advanced GUI installer and I need to figure out how to get it to look for for a file in a specific location and then if not there copy it? Also how do I run system shell commands via the xcode C++?



yeroen
Jun 18, 2008, 07:48 AM
Use the C standard library. For file handling fopen() etc, and for running shell commands either system() or popen().

trey5498
Jun 18, 2008, 07:56 AM
so the fopen() will allow me to see if a file exist and if not copy it there?

white89gt
Jun 18, 2008, 07:56 AM
NSFileManagers can do what you're talking about if you're using Cocoa and Objective-c. Otherwise you're stuck with what yeroen mentioned.

lazydog
Jun 18, 2008, 08:05 AM
so the fopen() will allow me to see if a file exist and if not copy it there?

This might sound sarcastic but it isn't - try typing fopen in Google. You'll soon pick up on trail of the information you need.

b e n

trey5498
Jun 18, 2008, 08:41 AM
I do appreciate, it has been a very long time since I have messed with C++. I have been using Perl mostly and the last time I used C++ was in college 8 years ago. I know it can be taken negatively, however I had no idea what to Google. File Handling comes up with some major weird stuff at first.

I do appreciate everything you have given me today as I am having to learn more advanced stuff for work (we are migrating to C++ from Perl although we will never stop using Perl ;) so I am not out of a job yet lol ).

I have two last questions, for now ;).


The first is about setting a value of checkboxes to an array. What I am thinking is something like this:


-(IBAction)Nextbutton:(id)sender
{

if([checkboxname isEqualToString:@"Printer1"] == YES) {

printerarray[i] = Printer1;
} else if{
the other 17 checkboxes
}



where hitting the next button would check to see if every checkbox is click or not, then pop up the next window and display the list of the printers in the array. The question is do I have the correct format and is this the best way?

The next question, I would still just use a standard text cell to display the list to confirm?

Thank you again in advance for your patience for my ignorance and for your advice and help.

yeroen
Jun 18, 2008, 09:32 AM
NSFileManagers can do what you're talking about if you're using Cocoa and Objective-c. Otherwise you're stuck with what yeroen mentioned.

I wouldn't call it "stuck", since the C API is simple, fast, portable and accessible from C, C++, and Objective C alike.

Actually, since this is C++, the OP should, for consistency, be using standard IOStreams classes (ifstream, ofstream, etc.) for file I/O.

trey5498
Jun 18, 2008, 01:34 PM
with using the Next button to display the next window, how do I have it preform two actions. I can either have it performClose on the main window or bring the next one out of hiding. How do I do both?

yeroen
Jun 18, 2008, 01:48 PM
both at the same time, or perform either one alternatively?

white89gt
Jun 18, 2008, 02:12 PM
I wouldn't call it "stuck", since the C API is simple, fast, portable and accessible from C, C++, and Objective C alike.

Actually, since this is C++, the OP should, for consistency, be using standard IOStreams classes (ifstream, ofstream, etc.) for file I/O.

You're right, stuck isn't the right word, and ifstreams and ofstreams are relatively easy to work with. cppreference.com is a great place to find info on C++ coding.

trey5498
Jun 18, 2008, 02:13 PM
basically both at the same time. The next button will basically close the main start screen, open the next one and then display a list of the printers you have decided to install.

trey5498
Jun 19, 2008, 08:11 AM
anyone?

yeroen
Jun 19, 2008, 10:45 AM
what do you have in your button callback right now?

trey5498
Jun 19, 2008, 10:59 AM
This is what I have in the script. However the interface building will only let me have one Sent action for the button though and it seems that the sent action is the only thing that is executed.



- (IBAction)NextButton:(ID)sender {
[prnSelector performClose:self];
[prnOverview orderFront:self];
}

trey5498
Jun 19, 2008, 11:11 AM
After a few more tests, it doesn't even look at the code in AppControler.m even when I drag AppController.h on top of the Blue box.

It just does whatever is in the the sent/received Actions

What did I do wrong?

yeroen
Jun 19, 2008, 11:42 AM
this, by the way, is why I hate IDEs

trey5498
Jun 19, 2008, 12:00 PM
How would I set this up any other way?

trey5498
Jun 19, 2008, 03:10 PM
How would you do this without IDE?