Перейти из форума на сайт.

НовостиФайловые архивы
ПоискАктивные темыТоп лист
ПравилаКто в on-line?
Вход Забыли пароль? Первый раз на этом сайте? Регистрация
Компьютерный форум Ru.Board » Компьютеры » Программы » FAR Manager (часть 6)

Модерирует : gyra, Maz

Maz (26-09-2022 12:52): FAR Manager (часть 7)  Версия для печати • ПодписатьсяДобавить в закладки
На первую страницук этому сообщениюк последнему сообщению

   

Alexyz21



Silver Member
Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору

Код:
-- lib.lua
-- v0.0.0.1
-- service lua library
 
local ffi = require("ffi")
 
ffi.cdef([[
typedef struct {
  void*          hwnd;
  uint32_t       wFunc;
  const wchar_t* pFrom;
  const wchar_t* pTo;
  unsigned short fFlags;
  int            fAnyOperationsAborted;
  void*          hNameMappings;
  const wchar_t* lpszProgressTitle;
} SHFILEOPSTRUCTW;
int SHFileOperationW(SHFILEOPSTRUCTW *);
]])
 
local FO = {  -- File Operation
  FO_MOVE               = 0x0001,  -- Move the files specified in pFrom to the location specified in pTo.
  FO_COPY               = 0x0002,  -- Copy the files specified in the pFrom member to the location specified in the pTo member.
  FO_DELETE             = 0x0003,  -- Delete the files specified in pFrom.
  FO_RENAME             = 0x0004   -- Rename the file specified in pFrom. You cannot use this flag to rename multiple files with a single function call. Use FO_MOVE instead.
}
 
local FOF = {  -- File Operation Flags
  FOF_SILENT            = 0x0004,  -- Do not display a progress dialog box.
  FOF_RENAMEONCOLLISION = 0x0008,  -- Give the file being operated on a new name in a move, copy, or rename operation if a file with the target name already exists at the destination.
  FOF_NOCONFIRMATION    = 0x0010,  -- Respond with Yes to All for any dialog box that is displayed.
  FOF_FILESONLY         = 0x0080,  -- Perform the operation only on files (not on folders) if a wildcard file name (.) is specified.
  FOF_NOERRORUI         = 0x0400,  -- Do not display a dialog to the user if an error occurs.
  FOF_NORECURSION       = 0x1000,  -- Only perform the operation in the local directory. Do not operate recursively into subdirectories, which is the default behavior.
  FOF_NORECURSEREPARSE  = 0x8000   -- Not used.
}
 
local function utf16(str)
  local strw = win.Utf8ToUtf16(str)
  local result = ffi.new("wchar_t[?]", #strw/2+1)
  ffi.copy(result, strw)
  return result
end
 
local function SHFileOp(wFunc, pFrom, pTo, fFlags)
  local _pFrom,_pTo = pFrom and type(pFrom)=="string",pTo and type(pTo)=="string"
  if FO[wFunc] and _pFrom and (wFunc=="FO_DELETE" or _pTo) then
    local fileopw  = ffi.new("SHFILEOPSTRUCTW")
    fileopw.wFunc  = FO[wFunc]
    fileopw.pFrom  = utf16(pFrom.."\0\0")
    fileopw.pTo    = utf16((pTo or "").."\0\0")
    local flags = 0
    if fFlags then
      local tpfFlags = type(fFlags)
      if     tpfFlags == "number" then flags = fFlags
      elseif tpfFlags == "table"  then for _,v in ipairs(fFlags) do flags = flags + (FOF[v] and FOF[v] or 0) end
      end
    end
    fileopw.fFlags = flags
    return 0 == ffi.load("shell32").SHFileOperationW(fileopw)
  end
end
 
return {
  SHFileOp = SHFileOp
}
 

Всего записей: 3484 | Зарегистр. 16-06-2007 | Отправлено: 07:41 09-07-2021 | Исправлено: Alexyz21, 12:41 09-07-2021
   

На первую страницук этому сообщениюк последнему сообщению

Компьютерный форум Ru.Board » Компьютеры » Программы » FAR Manager (часть 6)
Maz (26-09-2022 12:52): FAR Manager (часть 7)


Реклама на форуме Ru.Board.

Powered by Ikonboard "v2.1.7b" © 2000 Ikonboard.com
Modified by Ru.B0ard
© Ru.B0ard 2000-2024

BitCoin: 1NGG1chHtUvrtEqjeerQCKDMUi6S6CG4iC

Рейтинг.ru