zoukankan      html  css  js  c++  java
  • 文件同步程序,Python和C写的DLL

     1 #coding:utf-8
     2 
     3 from ctypes import *
     4 from FileCopy import *
     5 
     6 def GetFilePathList(FilePath):
     7     dll = CDLL(r"F:VSProjectFileFunction20190101DllReleaseFileFunction20190101Dll.dll")
     8     Length = c_int(0)
     9     return dll.TraversFileInterface(FilePath)
    10 
    11 des = 'E:Pictures'
    12 src = 'J:Video&Pictures'
    13 
    14 
    15 #源路径文件列表获取
    16 psrcchar = GetFilePathList(src)
    17 szSrcBuffer = c_char_p(psrcchar)
    18 SrcFilePath = szSrcBuffer.value
    19 SrcFilePathList = SrcFilePath.split('
    ')
    20 
    21 #目标文件列表获取
    22 pdeschar = GetFilePathList(des)
    23 szDesBuffer = c_char_p(pdeschar)
    24 DesFilePath = szDesBuffer.value
    25 DesFilePathList = DesFilePath.split('
    ')
    26 
    27 #生成目标路径比对集合
    28 DesFileSet = set()
    29 for FilePath in DesFilePathList:
    30     #print FilePath.split('\')[-1]
    31     DesFileSet.add(FilePath.split('\')[-1])
    32 
    33 NewSrcFileList = []
    34 #根据目标路径内容剔除已存在文件
    35 for FilePath in SrcFilePathList:
    36     #print FilePath.split('\')[-1]
    37     if FilePath.split('\')[-1] not in DesFileSet:
    38         NewSrcFileList.append(FilePath)
    39 
    40 #根据目的地址路径对源文件列表进行改造替换,生成拷贝目的地址
    41 DesCopyList = []
    42 for FilePath in NewSrcFileList:
    43     CopyPath = FilePath.replace(src, des)
    44     CopyPath = CopyPath[0:CopyPath.rfind('\')+1]
    45     CopyFromSrcToDes (FilePath, CopyPath)
    46     #DesCopyList.append(CopyPath)
    47 
    48 print len(NewSrcFileList)
    49 print len(DesCopyList)
    50 #dll.PrintHex(filedata, len(filedata))

    FileCopy文件

     1 import os
     2 
     3 def CopyFileByList():
     4     return
     5 
     6 def CopyFromSrcToDes(src, des):
     7     cmdname = 'xcopy ' + '"' + src + '"' + ' "' + des + '"'
     8     RunCmd(cmdname)
     9     return
    10 
    11 def RunCmd(cmd):
    12     print cmd
    13     ret = os.system(cmd)
    14     return
  • 相关阅读:
    ubuntu 安装docker
    docker 版本与查看某个容器详情信息
    linux namespace 分为有名和无名两种,默认情况下都是有名的
    查看centos 版本信息
    centos7 一键安装openstack 方法
    centos8 安装openstack (失败告终),参见centos7安装
    Windows7 安装docker工具的方法
    网络架构--防火墙双机热备(主备、负载均衡)
    ubuntu server 无线网口配置
    ubuntu server 18.04 单机安装openstack
  • 原文地址:https://www.cnblogs.com/matrix-r/p/10548835.html
Copyright © 2011-2022 走看看