Source Code for Me (s-c.me)

Allows you to paste souce code to blogs! Adapted for Twitter! Here is Search Form in case you missed your code.
Tags: CSharp,Downloader,DFile,eDFileState, Created At: 10/24/2016 8:26:12 PMViews:

HTML view:
Copy Source | Copy HTML
 
class Downloader
{
public:
    class DFile
    {
    public:
        enum eDFileState
        {
            DFILE_STATE_NONE =  0, // Ð•Ñ‰Ñ‘ Ð½Ðµ Ð½Ð°Ñ‡Ð°Ð»Ð¸ ÑÐºÐ°Ñ‡ÐºÑƒ ( Ð½Ðµ Ð²Ñ‹Ð·Ñ‹Ð²Ð°Ð»Ð¸ Work )
            DFILE_STATE_DOWNLOADING = 1, // Ð˜Ð´ÐµÑ‚ Ð¿Ñ€Ð¾Ñ†ÐµÑÑ ÑÐºÐ°Ñ‡ÐºÐ¸
            DFILE_STATE_ERROR = 2, // ÐŸÑ€Ð¾Ð¸Ð·Ð¾ÑˆÐ»Ð° Ð¾ÑˆÐ¸Ð±ÐºÐ° ( GetError Ð¿Ð¾Ð´Ñ€Ð¾Ð±Ð½Ð¾ÑÑ‚и )
            DFILE_STATE_COMPLETE = 3, // Ð£ÑÐ¿ÐµÑˆÐ½Ð¾ ÑÐºÐ°Ñ‡Ð°Ð½Ð¾
        };
        DFile(); // ÐšÐ¾Ð½ÑÑ‚руктор, Ð¾Ð±Ð½ÑƒÐ»ÑÐµÑ‚ Ð´Ð°Ð½Ð½Ñ‹Ðµ
        ~DFile(); // Ð”еструктор, Ñ‡Ð¸ÑÑ‚ит Ð·Ð° ÑÐ¾Ð±Ð¾Ð¹
        void Clean(); // ÐžÑ‡Ð¸ÑÑ‚ить Ð´Ð°Ð½Ð½Ñ‹Ðµ, Ñ‡Ñ‚о Ð±Ñ‹ Ð¼Ð¾Ð¶Ð½Ð¾ Ð±Ñ‹Ð»Ð¾ Ð¸ÑÐ¿Ð¾Ð»ÑŒÐ·Ð¾Ð²Ð°Ñ‚ÑŒ Ð¾Ð±ÑŠÐµÐºÑ‚ Ð¿Ð¾Ð²Ñ‚орно
 
        void SetURL( const char* sUrl ); // Ð£ÑÑ‚ановить ÑƒÑ€Ð» Ð´Ð»Ñ ÑÐºÐ°Ñ‡ÐºÐ¸
        void SetToFile( const char* sToFile ); // Ð£ÑÑ‚ановить Ñ„айл Ð´Ð»Ñ Ð·Ð°Ð¿Ð¸ÑÐ¸, ÐµÑÐ»Ð¸ Ð½Ðµ ÑƒÑÑ‚ановлен ÑÐºÐ°Ñ‡ÐºÐ° Ð¿Ñ€Ð¾Ð¸ÑÑ…одит Ð² Ð±ÑƒÑ„фер
        void SetUserAgent( const char* sUserAgent ); // Ð£ÑÑ‚ановить ÑÑ‚року UserAgent
        void SetFileBadAttempts( int iFileBadAttempts ) { _iFileBadAttempts = iFileBadAttempts; } // Ð£ÑÑ‚ановить ÑÐºÐ¾Ð»ÑŒÐºÐ¾ Ð´Ð¾Ð¿ÑƒÑÑ‚имо Ð¾ÑˆÐ¸Ð±Ð¾Ðº
 
        // Ð¡ÐºÐ°Ñ‡ÐºÐ° Ð·Ð°Ð²ÐµÑ€ÑˆÐ¸Ð»Ð°ÑÑŒ ? Ð’АЖНО! ÐŸÐ¾ÐºÐ° ÑÐºÐ°Ñ‡ÐºÐ° Ð½Ðµ Ð±ÑƒÐ´ÐµÑ‚ Ð·Ð°Ð²ÐµÑ€ÑˆÐµÐ½Ð°, Ð¾Ð±ÑŠÐµÐºÑ‚ Ð½ÐµÐ»ÑŒÐ·Ñ ÑƒÐ´Ð°Ð»ÑÑ‚ÑŒ, GetState == DFILE_STATE_DOWNLOADING
        int GetState() { return _iState; }
        const char* GetError() { return _sError.Get(); }
        const size_t GetLength() { return _iLength; } // ÐŸÐ¾Ð»ÑƒÑ‡Ð¸Ñ‚ÑŒ Ð´Ð»Ð¸Ð½Ð½Ñƒ ÑÐºÐ°Ñ‡Ð°Ð½Ð½Ñ‹Ñ… Ð´Ð°Ð½Ð½Ñ‹Ñ…
        const UCHAR* GetData() { return _pData; } // ÐŸÐ¾Ð»ÑƒÑ‡Ð¸Ñ‚ÑŒ Ð´Ð°Ð½Ð½Ñ‹Ðµ
        float GetPercent() { return _fPercentComplete; } // ÐŸÐ¾Ð»ÑƒÑ‡Ð¸Ñ‚ÑŒ Ð·Ð°Ð²ÐµÑ€ÑˆÐµÐ½Ð½Ð¾ÑÑ‚ÑŒ ÑÐºÐ°Ñ‡ÐºÐ¸
 
        static size_t CallbackWriteMemory( void* pNewData, size_t size, size_t nmemb, DFile* pDFile ); // Ð“отов ÐºÑƒÑÐ¾Ðº Ð´Ð»Ñ Ð·Ð°Ð¿Ð¸ÑÐ¸ Ð² Ð±ÑƒÑ„фер
        static size_t CallbackWriteStream( void* pNewData, size_t size, size_t nmemb, FILE *stream ); // Ð“отов ÐºÑƒÑÐ¾Ðº Ð´Ð»Ñ Ð·Ð°Ð¿Ð¸ÑÐ¸ Ð² Ñ„айл
        static int CallbackProgress( DFile* pDFile, double t, double d, double ultotal, double ulnow ); // ÐžÐ±Ð½Ð¾Ð²Ð¸Ð»ÑÑ ÑÑ‚атус Ð³Ð¾Ñ‚овности ÑÐºÐ°Ñ‡ÐºÐ¸
 
        void DownloadThread(); // Ð¡ÐºÐ°Ñ‡Ð°Ñ‚ÑŒ, Ð·Ð°Ð¿ÑƒÑÐºÐ°ÐµÑ‚ Ð² Ð¾Ñ‚дельном Ð¿Ð¾Ñ‚оке Ð¼ÐµÑ‚од Work
        void Work(); // ÐÐµÐ¿Ð¾ÑÑ€ÐµÐ´ÑÑ‚венная Ð¾Ð±Ñ€Ð°Ð±Ð¾Ñ‚ка ÑÐºÐ°Ñ‡ÐºÐ¸
 
    private:
        String _sURL; // Ð¡Ð¾Ð±ÑÑ‚венно Ð¾Ñ‚куда ÑÐºÐ°Ñ‡Ð¸Ð²Ð°ÐµÐ¼
        String _sToFile; // ÐšÑƒÐ´Ð° ÑÐ¾Ñ…ранить ( Ð½Ð° Ð´Ð¸ÑÐºÐµ )
        String _sError; // ÐŸÐ¾Ð»ÑƒÑ‡Ð¸Ñ‚ÑŒ Ð¸Ð½Ñ„ормацию Ð¾Ð± Ð¾ÑˆÐ¸Ð±ÐºÐµ
        String _sUserAgent; // Ð¡Ñ‚рока HTTP Ð·Ð°Ð³Ð¾Ð»Ð¾Ð²ÐºÐ° UserAgent
 
        UCHAR* _pData; // ÐšÑƒÐ´Ð° ÑÐ¾Ñ…ранить ( Ð² Ð¿Ð°Ð¼ÑÑ‚и )
        size_t _iLength; // Ð¡ÐºÐ¾Ð»ÑŒÐºÐ¾ Ð±Ð°Ð¹Ñ‚ ÑÐºÐ°Ñ‡Ð°Ð½Ð½Ð¾
        float _fPercentComplete; // ÐŸÑ€Ð¾Ñ†ÐµÐ½Ñ‚ Ð·Ð°Ð²ÐµÑ€ÑˆÐµÐ½Ð½Ð¾ÑÑ‚и
        int _iState; // Ð¡Ð¾ÑÑ‚ояние Ð·Ð°ÐºÐ°Ñ‡ÐºÐ¸
        int _iFileBadAttempts; // ÐœÐ°ÐºÑ ÐºÐ¾Ð»Ð¸Ñ‡ÐµÑÑ‚во Ð½ÐµÑƒÐ´Ð°Ñ‡Ð½Ñ‹Ñ… Ð¿Ð¾Ð¿Ñ‹Ñ‚ок ÑÐºÐ°Ñ‡ÐºÐ¸, Ð¸ÑÐ¿Ð¾Ð»ÑŒÐ·ÑƒÐµÑ‚ся Ð´Ð»ÑÐ²Ð°Ñ€Ð¸Ð°Ð½Ñ‚а Ñ Ð·Ð°Ð¿Ð¸ÑÑŒÑŽ Ð² Ñ„айл ( Ð¾Ð±Ñ€Ñ‹Ð²Ñ‹ ÑÐ²ÑÐ·Ð¸ Ð½Ð°Ð¿Ñ€Ð¸Ð¼ÐµÑ€ )
    };
 
    static void Init(); // Ð˜Ð½Ð¸Ñ†Ð¸Ð°Ð»Ð¸Ð·Ð¸Ñ€Ð¾Ð²Ð°Ñ‚ÑŒ Ð½ÐµÐ¾Ð±Ñ…одиммые Ð´Ð°Ð½Ð½Ñ‹Ðµ
    static void Destroy(); // ÐŸÐ¾Ñ‡Ð¸ÑÑ‚ить Ð·Ð° ÑÐ¾Ð±Ð¾Ð¹
 
};

Based on Manoli.Net's CodeFormatter. Made by Topbot (c) 2008-2017