MCPcopy Index your code
hub / github.com/codeaashu/claude-code / validateAttachmentPaths

Function validateAttachmentPaths

src/tools/BriefTool/attachments.ts:26–61  ·  view source on GitHub ↗
(
  rawPaths: string[],
)

Source from the content-addressed store, hash-verified

24}
25
26export async function validateAttachmentPaths(
27 rawPaths: string[],
28): Promise<ValidationResult> {
29 const cwd = getCwd()
30 for (const rawPath of rawPaths) {
31 const fullPath = expandPath(rawPath)
32 try {
33 const stats = await stat(fullPath)
34 if (!stats.isFile()) {
35 return {
36 result: false,
37 message: `Attachment "${rawPath}" is not a regular file.`,
38 errorCode: 1,
39 }
40 }
41 } catch (e) {
42 const code = getErrnoCode(e)
43 if (code === 'ENOENT') {
44 return {
45 result: false,
46 message: `Attachment "${rawPath}" does not exist. Current working directory: ${cwd}.`,
47 errorCode: 1,
48 }
49 }
50 if (code === 'EACCES' || code === 'EPERM') {
51 return {
52 result: false,
53 message: `Attachment "${rawPath}" is not accessible (permission denied).`,
54 errorCode: 1,
55 }
56 }
57 throw e
58 }
59 }
60 return { result: true }
61}
62
63export async function resolveAttachments(
64 rawPaths: string[],

Callers 1

validateInputFunction · 0.85

Calls 4

getCwdFunction · 0.85
expandPathFunction · 0.85
statFunction · 0.85
getErrnoCodeFunction · 0.85

Tested by

no test coverage detected