• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            天下

            記錄修行的印記

            loop cp 代碼

            //測試工具
            #include <unistd.h>
            #include 
            <cstring>
            #include 
            <cstdlib>
            #include 
            <string>
            #include 
            <sys/socket.h>
            #include 
            <netinet/tcp.h>
            #include 
            <sys/ioctl.h> 
            #include 
            <netinet/in.h>
            #include 
            <arpa/inet.h>
            #include 
            <dirent.h>    
            #include 
            <sys/time.h>
            #include 
            <assert.h>
            #include 
            <errno.h>
            #include 
            <sys/types.h>
            #include 
            <sys/stat.h>
            #include 
            <fcntl.h>
            #include 
            <assert.h>

            using namespace std;

            void Path_AddSlash(char* pszPath)
            {
                assert(pszPath
            !=NULL);
            #ifdef WIN32
                PathAddBackslash(pszPath);
            #else
                
            int nLen = strlen(pszPath);
                
            if (pszPath[nLen-1]!='/')
                {
                    pszPath[nLen] 
            = '/';
                    pszPath[nLen
            +1= '\0';
                }
            #endif
            }


            #ifndef WIN32
            unsigned 
            int GetTickCount()
            {
                
            struct timeval tv;
                
            if(gettimeofday(&tv, NULL)!= 0)
                    
            return 0;
                
            return (tv.tv_sec * 1000)+(tv.tv_usec/1000); 
            }
            #endif

            string Path_GetBaseName(const string& strPath)
            {
                
            const char* pszPath = strPath.c_str();
            #ifdef WIN32
                
            char name[256];
                
            char ext[256];
                _splitpath(pszPath,NULL,NULL,name,ext);
                strcat(name,ext);
                
            return string(name);
            #else
                
            return string(basename(pszPath));
            #endif
            }

            // 目錄是否存在
            bool IsDirectory(char *p_dir)
            {
                DIR 
            *dir = NULL;

                dir 
            = opendir(p_dir);
                
            if( NULL == dir )
                {
                    
            return false;
                }
                
            else
                {
                    closedir(dir);
                    
            return true;
                }
            }

            long GetLocalFileSize(const char* szFileName)
            {
                
            struct stat f_stat;
                
            if (stat(szFileName, &f_stat) == -1) {
                    
            return -1;
                }
                
            return (long)f_stat.st_size;
            }


            int main(int argc,char* argv[])
            {
                
            char szCmd[512];
                
            char szDstFileName[256];
                
            char szDir[256];

                
            if (argc!=5)
                {
                    printf(
            "Usage:%s <filename> <dirpath> <begin> <end> \r\n",argv[0]);
                    
            return 255;
                }
                
                
            char* pszFileName = argv[1];
                
            int nBegin    = atoi(argv[3]);
                
            int nEnd    = atoi(argv[4]);

                strcpy(szDir,argv[
            2]);

                
            if (GetLocalFileSize(pszFileName) < 0)
                {
                    printf(
            "error:<%s> is not exist \r\n",pszFileName);
                    
            return 255;
                }
                
                
            if (!IsDirectory(szDir))
                {
                    printf(
            "error:<%s> is not directory \r\n",szDir);
                    
            return 255;
                }
                
                unsigned 
            int dwBeginTime = GetTickCount();

                Path_AddSlash(szDir);
                
            char* pszExtName = strchr(pszFileName,'.');
                
            if (pszExtName==NULL)
                {
                    pszExtName 
            = (char*)"";
                }

                
            int ret = 0;
                
            int i = 0;
                
            for (i=nBegin;i<nEnd;i++)
                {
                    sprintf(szCmd,
            "cp %s %s%06d%s",pszFileName,szDir,i,pszExtName);
                    puts(szCmd);
                    ret 
            = system(szCmd);
                    
            if (ret!=0)
                    {
                        
            break;
                    }
                }
                unsigned 
            int dwEndTime = GetTickCount();
                puts(
            "\r\n-------------------------------------------------------------------");
                printf(
            "from:%d,to:%d \r\n",nBegin,nEnd);
                printf(
            "begin time:%u,end time:%u \r\n",dwBeginTime,dwEndTime);
                printf(
            "elapse ms:%u \r\n",dwEndTime - dwBeginTime);
                
            return 0;
            }

            posted on 2012-12-06 14:37 天下 閱讀(325) 評論(0)  編輯 收藏 引用 所屬分類: Linux編程

            <2011年3月>
            272812345
            6789101112
            13141516171819
            20212223242526
            272829303112
            3456789

            導航

            統計

            常用鏈接

            留言簿(4)

            隨筆分類(378)

            隨筆檔案(329)

            鏈接

            最新隨筆

            搜索

            最新評論

            久久国产精品免费一区| 久久久久一区二区三区| 欧美一区二区精品久久| 久久天天躁狠狠躁夜夜96流白浆 | 久久久无码精品亚洲日韩按摩| 久久一区二区免费播放| 国内精品久久久久久久coent| 狠色狠色狠狠色综合久久 | 久久久久久无码Av成人影院| 一本一本久久A久久综合精品| 久久SE精品一区二区| 色综合久久无码五十路人妻| 久久精品aⅴ无码中文字字幕重口| 欧美熟妇另类久久久久久不卡| 久久狠狠爱亚洲综合影院| 亚洲AV无码久久精品色欲| 久久亚洲精品人成综合网| 久久99精品国产99久久6男男| 亚洲综合婷婷久久| 久久亚洲av无码精品浪潮| 亚洲中文字幕久久精品无码喷水| 亚洲精品无码久久久久去q| 久久亚洲中文字幕精品有坂深雪 | 武侠古典久久婷婷狼人伊人| 色老头网站久久网| 国产精品gz久久久| 一本综合久久国产二区| 亚洲AV无码久久精品成人| 国产一久久香蕉国产线看观看| 色综合久久久久网| 人妻丰满?V无码久久不卡| 99久久国产综合精品女同图片| 66精品综合久久久久久久| 香蕉久久影院| 中文精品久久久久国产网址| 亚洲七七久久精品中文国产| 狠狠色噜噜狠狠狠狠狠色综合久久| yy6080久久| 久久国产精品一区| 91精品国产高清91久久久久久| 伊人热热久久原色播放www|