Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Feb 23rd, 2010, 7:04 PM   #1
squills
Professional Programmer
 
squills's Avatar
 
Join Date: Feb 2009
Posts: 280
Rep Power: 2 squills is on a distinguished road
Auto create

Hello, Iam trying to make a program to do something for me. Though I did it in php for linux system, I dont think i can use it in windows.. So its c++ time

I have a folder called "done" when any file goes into done it opens maketorrent and then creates a .torrent file and saves it into a file called "tdone"

Any clue on how to do this :O or even better were to start?

Thanks
squill
__________________
Best use ever for C++...
http://www.planet-source-code.com/Up...3165921697.jpg
squills is offline   Reply With Quote
Old Feb 23rd, 2010, 8:14 PM   #2
King
Professional Programmer
 
King's Avatar
 
Join Date: Jan 2006
Location: Ontario, Canada
Posts: 417
Rep Power: 5 King is on a distinguished road
Re: Auto create

This doesn't sound too complex. You should try and break it down into sections.

First, you need code to check if a file exists; this can be done using fstream (Google this, there will be lots of examples).

Next you the have to put this in a loop to keep checking for a file. Inside this loop you can check if the file exists, if it doesn't, sleep for a minute, or however long you want, when the sleep is over it will check again. You will not want the sleep to be too short or it will bog down your system.

Once the file is found you can process it. I am not familiar with MakeTorrent, but if you can call it from command line passing in the file you found as a parameter, it should be pretty easy to call from c++. There are a few options for calling processes from c++; you said you were writing this in Windows, so the win32 function CreateProcess should do the trick.

This is how I would break it down. Hopefully this gets the thought process moving.
__________________
I am Addicted to Linux!
King is offline   Reply With Quote
Old Feb 23rd, 2010, 9:10 PM   #3
squills
Professional Programmer
 
squills's Avatar
 
Join Date: Feb 2009
Posts: 280
Rep Power: 2 squills is on a distinguished road
Re: Auto create

Thanks, Seam to hit it on the head..going to do some research, as i was practicing using php threw line command.. anyhow maketorrent can be called but must use MinGW which is kind of new to me.. soo off to do alot of research.. and sure ill have questions later

thanks again
squills


also
Quote:
First, you need code to check if a file exists; this can be done using fstream (Google this, there will be lots of examples).
i need it to more or less trigger the maketorrent when something new is added as there could be alot of files in this folder all ready, soo when a new file is added it will pass that info to make torrent.. woudl you still suggest using fstream to check?
thanks
squills
__________________
Best use ever for C++...
http://www.planet-source-code.com/Up...3165921697.jpg
squills is offline   Reply With Quote
Old Feb 23rd, 2010, 10:50 PM   #4
King
Professional Programmer
 
King's Avatar
 
Join Date: Jan 2006
Location: Ontario, Canada
Posts: 417
Rep Power: 5 King is on a distinguished road
Re: Auto create

Quote:
Originally Posted by squills View Post
i need it to more or less trigger the maketorrent when something new is added as there could be alot of files in this folder all ready, soo when a new file is added it will pass that info to make torrent.. woudl you still suggest using fstream to check?
What you will have to do is when your program first starts is read in all the files in that directory into a list, then every time you check for a new file, you can read the contents of the directory and compare it to that list to see if there are any new files. I do not think fstream can read the directory to get a list of files, but the boost library can:
http://www.boost.org/
__________________
I am Addicted to Linux!
King is offline   Reply With Quote
Old Feb 23rd, 2010, 11:20 PM   #5
squills
Professional Programmer
 
squills's Avatar
 
Join Date: Feb 2009
Posts: 280
Rep Power: 2 squills is on a distinguished road
Re: Auto create

ok , i got a good idea on this firs part.. But whats buggin me is the maketorrent file i have to run is a makefile, so i used in linux this code.. but not sure how to write it for windows and haveing to have it use MinGW

echo shell_exec('./mktorrent -a http://blahblah.net/announce.php -o '.$TmpDir.$Item.'.torrent '.$GotDir.$Item.'/');

any idea's on this...
__________________
Best use ever for C++...
http://www.planet-source-code.com/Up...3165921697.jpg
squills is offline   Reply With Quote
Old Feb 24th, 2010, 7:47 AM   #6
King
Professional Programmer
 
King's Avatar
 
Join Date: Jan 2006
Location: Ontario, Canada
Posts: 417
Rep Power: 5 King is on a distinguished road
Re: Auto create

You can use the CreateProcess function I mentioned above. Basically it takes the application name as the first param (mktorrent), and then the rest of the parameters you pass in with it. To use this you will probably have to include the windows header file. More information can be found here:
http://msdn.microsoft.com/en-us/libr...8VS.85%29.aspx

Another thread I found on running external programs from c/c++:
http://www.dreamincode.net/forums/in...howtopic=18057
__________________
I am Addicted to Linux!

Last edited by King; Feb 24th, 2010 at 7:57 AM. Reason: Added link
King is offline   Reply With Quote
Old Feb 24th, 2010, 10:07 PM   #7
squills
Professional Programmer
 
squills's Avatar
 
Join Date: Feb 2009
Posts: 280
Rep Power: 2 squills is on a distinguished road
Re: Auto create

Thanks for your help, I belive its working
__________________
Best use ever for C++...
http://www.planet-source-code.com/Up...3165921697.jpg
squills is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Open Source free HonoCMS (asp,php,jsp.net) auto code generate hightgig Show Off Your Open Source Projects 3 Jun 9th, 2010 1:01 AM
Problem to create a global object, to use objects created inside a method etc... colt Java 2 Jul 12th, 2009 1:52 PM
fedora USB create boot image script kdepfyffer Bash / Shell Scripting 2 May 25th, 2005 8:31 AM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 11:07 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC