FileNameValidator+Extensions.swift 1.0 KB

1234567891011121314151617181920212223242526
  1. //
  2. // FileNameValidator+Extensions.swift
  3. // Nextcloud
  4. //
  5. // Created by Milen Pivchev on 26.08.24.
  6. // Copyright © 2024 Marino Faggiana. All rights reserved.
  7. //
  8. import NextcloudKit
  9. extension FileNameValidator {
  10. private func setup(account: String?) {
  11. let capabilities = NCCapabilities.shared.getCapabilities(account: account)
  12. FileNameValidator.shared.setup(forbiddenFileNames: capabilities.capabilityForbiddenFileNames, forbiddenFileNameBasenames: capabilities.capabilityForbiddenFileNameBasenames, forbiddenFileNameCharacters: capabilities.capabilityForbiddenFileNameCharacters, forbiddenFileNameExtensions: capabilities.capabilityForbiddenFileNameExtensions)
  13. }
  14. func checkFileName(_ filename: String, account: String?) -> NKError? {
  15. setup(account: account)
  16. return FileNameValidator.shared.checkFileName(filename)
  17. }
  18. func checkFolderPath(_ folderPath: String, account: String?) -> Bool {
  19. setup(account: account)
  20. return FileNameValidator.shared.checkFolderPath(folderPath)
  21. }
  22. }