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
  • 相关阅读:
    面相对象2016/4/19
    2016/4/19
    ajax2016/4/15 post与get
    iframe2016/4/12
    Hibernate报错解决Error parsing JNDI name [],Need to specify class name
    vue-router 源码解析最简版
    vue数据响应式原理
    3-箭头函数与普通函数
    2.1.7 html的处理与打包
    2.1.6 css的编译与处理 -2
  • 原文地址:https://www.cnblogs.com/matrix-r/p/10548835.html
Copyright © 2011-2022 走看看