Raised This Month: $32 Target: $400
 8% 

Module: Download


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 02-27-2011 , 14:23   Module: Download
Reply With Quote #1

Update 2013-07-31: I removed the binary. It was a shitty module. If anyone is interested I'll leave the source, but have in mind it's much better to use sockets for three reasons. 1. Everyone has it. 2. It won't crash like this do. 3. It's easier to work with.

Please refer to my HTTP2 include instead of this module.

Download 1.0

Enables plugins to download files from http sources.
Basically a wrapper for URLDownloadToFile.
More info on that function:
http://msdn.microsoft.com/en-us/library/ms775123.aspx

Could enable, for example, auto-updating of plugins. (Not alone though)
Known problem:
When I placed 6+ downloads at server startup it would crash on me at restart. (Not first start) Reason: unknown. I'm not that good at C++... Either way, it basically works.

PHP Code:
/*
* native DownloadStart(const url[], const file[]);
*     Start the download of a file from http source.

* Arguments:

*     const url[]:
*         Source URL to download from.

*     const file[]:
*         Local filename to save to.
*         Can be used both with "C:\file.ext" or "/file.ext".
*         The latest will save the file under moddir.

* Returns:

*     On success:
*         Download Id
*             Integer 0-9
*     On fail:
*         -1
*             Error message displayed in console.

*     Note:    0-9 does not guarantee success.
*             If I was to make the module wait for the
*             status of the file, it will freeze the server.
*             You need to use the DownloadFailed forward.
*             If that forward is never called, successful.
* */
native DownloadStart(const url[], const file[]);


/*
* native DownloadAbort(Id);
*     Aborts a download.

* Arguments:

*     Id:
*         Download Id to abort.


* Returns:
*     0
* */
native DownloadAbort(Id);

/*
* forward DownloadDone(Id, KBDone, KBTotal);
*     This forward is called when any file is finished.

* Arguments:

*     Id:
*         Current Download Id.

*     KBDone:
*         KiBiBytes downloaded.

*     KBTotal
*         KiBiBytes total.

* Possible return values:
*     Return value is ignored.
* */
forward DownloadDone(IdKBDoneKBTotal);

/*
* forward Downloading(Id, BDone, BTotal);
*     This forward is called as long as any file is downloading.

* Arguments:

*     Id:
*         Current Download Id.

*     KBDone:
*         KiBiBytes downloaded.

*     KBTotal
*         KiBiBytes total.

* Possible return values:
*     Return value is ignored.
* */
forward Downloading(IdKBDoneKBTotal);

/*
* forward DownloadFailed(Id);
*     This forward is called when a download fail.
*     Reason is specified in console.

* Arguments:

*     Id:
*         The download Id that failed.

*     ErrorId:
*         The Id of the error, more information:
*         http://msdn.microsoft.com/en-us/library/ms775145.aspx

* Possible return values:
*     Return value is ignored.
* */
forward DownloadFailed(IdErrorId); 
Kind regards
Black Rose, also known here as [ --<-@ ] Black Rose or DivinityX
Attached Files
File Type: inc Download.inc (2.1 KB, 333 views)
File Type: zip Download Source.zip (116.9 KB, 312 views)

Last edited by Black Rose; 09-08-2013 at 07:04.
Black Rose is offline
ot_207
Veteran Member
Join Date: Jan 2008
Location: Romania The Love Country
Old 02-27-2011 , 15:14   Re: Module: Download
Reply With Quote #2

Just lol, and gj.
Will test this.
Maybe a port to linux?
__________________
My approved plug-ins | Good for newbies! | Problems?

Back, will come around when I have time.
ot_207 is offline
fmfs10
Senior Member
Join Date: Mar 2009
Location: Brasil
Old 02-27-2011 , 15:26   Re: Module: Download
Reply With Quote #3

You can make the possibility of compress files and uncompress this. Or just the ability of uncompress files after download a compressed files. It would help a lot servers when downloading big files (like models)

EDIT@

You should add the ability to read file version url side too =P
fmfs10 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-27-2011 , 16:25   Re: Module: Download
Reply With Quote #4

Is this supposed to be an alternative to FTP? I think I would always prefer FTP.
__________________
fysiks is offline
fmfs10
Senior Member
Join Date: Mar 2009
Location: Brasil
Old 02-27-2011 , 17:29   Re: Module: Download
Reply With Quote #5

Quote:
Originally Posted by fysiks View Post
Is this supposed to be an alternative to FTP? I think I would always prefer FTP.
I don't know but I think it can change the file. FTP can't delete a data =x
fmfs10 is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 02-27-2011 , 17:37   Re: Module: Download
Reply With Quote #6

Quote:
Originally Posted by ot_207 View Post
Just lol, and gj.
Will test this.
Maybe a port to linux?
I don't know anything about linux.
All my modules are based on Windows functions.

Quote:
Originally Posted by fmfs10 View Post
You can make the possibility of compress files and uncompress this. Or just the ability of uncompress files after download a compressed files. It would help a lot servers when downloading big files (like models)
uncompress files is easily done with my ExecuteX plugin, combined win rar.exe (command line WinRAR). I might add it, but I wouldn't count on it.
As stated, I'm not that good at C++.
Quote:
Originally Posted by fmfs10 View Post
You should add the ability to read file version url side too =P
I don't quite understand what you mean. You can download a website and parse it like any file.

Quote:
Originally Posted by fysiks View Post
Is this supposed to be an alternative to FTP? I think I would always prefer FTP.
I don't understand. This works on ftp aswell.

Last edited by Black Rose; 02-27-2011 at 18:09.
Black Rose is offline
fmfs10
Senior Member
Join Date: Mar 2009
Location: Brasil
Old 02-27-2011 , 18:19   Re: Module: Download
Reply With Quote #7

Quote:
Originally Posted by Black Rose View Post
I don't quite understand what you mean. You can download a website and parse it like any file.
If you want to update a file, you need to know the file version from the url (the updated) and the server (the possible outdated). So you need to compare the file version from url and from the server...
fmfs10 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-27-2011 , 23:28   Re: Module: Download
Reply With Quote #8

Quote:
Originally Posted by Black Rose View Post
I don't understand. This works on ftp aswell.
It would be much easier for me and more efficient for the server for me to just upload the files that I want on the server.

I know there are plugins that download crap but I would never use them.
__________________
fysiks is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 02-27-2011 , 19:26   Re: Module: Download
Reply With Quote #9

Well, that's a waste of time then.

It's way better to use sockets since everyone has that.
Black Rose is offline
AntiBots
Veteran Member
Join Date: May 2008
Location: Brazil
Old 02-28-2011 , 01:47   Re: Module: Download
Reply With Quote #10

you don't need to create 10 functions. You have the "dummy" param to send information.
__________________
AntiBots is offline
Send a message via ICQ to AntiBots Send a message via MSN to AntiBots Send a message via Skype™ to AntiBots
Reply



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


All times are GMT -4. The time now is 15:42.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode