• <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 天下 閱讀(329) 評論(0)  編輯 收藏 引用 所屬分類: Linux編程

            <2011年9月>
            28293031123
            45678910
            11121314151617
            18192021222324
            2526272829301
            2345678

            導航

            統計

            常用鏈接

            留言簿(4)

            隨筆分類(378)

            隨筆檔案(329)

            鏈接

            最新隨筆

            搜索

            最新評論

            一本久久精品一区二区| 久久夜色精品国产亚洲| 久久综合色区| 久久久久亚洲AV成人网人人网站| 久久精品国产亚洲Aⅴ香蕉| 欧美一级久久久久久久大| 国产精品中文久久久久久久| 香蕉久久av一区二区三区| 天天久久狠狠色综合| 热久久视久久精品18| 91精品国产91久久综合| 四虎影视久久久免费观看| 蜜臀av性久久久久蜜臀aⅴ麻豆| 青青草国产精品久久久久| 四虎国产精品成人免费久久| 久久精品国产亚洲av麻豆小说| 久久精品国产亚洲一区二区三区| 久久精品国产色蜜蜜麻豆| 99久久精品免费| 精品久久久久香蕉网| 精品久久久一二三区| 久久国产视频网| 精品久久久久久亚洲| 伊人久久大香线蕉av不变影院| 久久av免费天堂小草播放| 精品蜜臀久久久久99网站| 久久精品国产亚洲αv忘忧草| 国产成人无码精品久久久久免费 | 久久久久综合网久久| 久久精品国产亚洲AV香蕉| 93精91精品国产综合久久香蕉| 少妇内射兰兰久久| 久久久久国产成人精品亚洲午夜| 麻豆AV一区二区三区久久 | 粉嫩小泬无遮挡久久久久久| 精品国产乱码久久久久软件| 久久久久99精品成人片三人毛片| 99久久免费只有精品国产| 曰曰摸天天摸人人看久久久| 久久福利青草精品资源站| 2021国产成人精品久久|