mirror of
https://github.com/SRI-CSL/gllvm
synced 2026-06-08 12:28:35 +00:00
reduce cyclomatic complexity for my GPA. Sucks.
This commit is contained in:
+52
-14
@@ -59,26 +59,64 @@ func getFileType(realPath string) (fileType int) {
|
||||
LogFatal("There was an error getting the type of %s. Make sure that the 'file' command is installed.", realPath)
|
||||
}
|
||||
|
||||
// Test the output
|
||||
if fo := string(out); strings.Contains(fo, "ELF") && strings.Contains(fo, "executable") {
|
||||
fileType = fileTypeELFEXECUTABLE
|
||||
} else if strings.Contains(fo, "Mach-O") && strings.Contains(fo, "executable") {
|
||||
fileType = fileTypeMACHEXECUTABLE
|
||||
} else if strings.Contains(fo, "ELF") && strings.Contains(fo, "shared") {
|
||||
fileType = fileTypeELFSHARED
|
||||
} else if strings.Contains(fo, "Mach-O") && strings.Contains(fo, "dynamically linked shared") {
|
||||
fileType = fileTypeMACHSHARED
|
||||
fo := string(out)
|
||||
|
||||
if strings.Contains(fo, "ELF") {
|
||||
|
||||
if strings.Contains(fo, "executable") {
|
||||
fileType = fileTypeELFEXECUTABLE
|
||||
} else if strings.Contains(fo, "shared") {
|
||||
fileType = fileTypeELFSHARED
|
||||
} else if strings.Contains(fo, "relocatable") {
|
||||
fileType = fileTypeELFOBJECT
|
||||
} else {
|
||||
fileType = fileTypeUNDEFINED
|
||||
}
|
||||
|
||||
|
||||
|
||||
} else if strings.Contains(fo, "Mach-O") {
|
||||
|
||||
if strings.Contains(fo, "executable") {
|
||||
fileType = fileTypeMACHEXECUTABLE
|
||||
} else if strings.Contains(fo, "dynamically linked shared") {
|
||||
fileType = fileTypeMACHSHARED
|
||||
} else if strings.Contains(fo, "object") {
|
||||
fileType = fileTypeMACHOBJECT
|
||||
} else {
|
||||
fileType = fileTypeUNDEFINED
|
||||
}
|
||||
|
||||
} else if strings.Contains(fo, "current ar archive") {
|
||||
fileType = fileTypeARCHIVE
|
||||
} else if strings.Contains(fo, "thin archive") {
|
||||
fileType = fileTypeTHINARCHIVE
|
||||
} else if strings.Contains(fo, "ELF") && strings.Contains(fo, "relocatable") {
|
||||
fileType = fileTypeELFOBJECT
|
||||
} else if strings.Contains(fo, "Mach-O") && strings.Contains(fo, "object") {
|
||||
fileType = fileTypeMACHOBJECT
|
||||
} else {
|
||||
} else {
|
||||
fileType = fileTypeUNDEFINED
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Test the output
|
||||
// if fo := string(out); strings.Contains(fo, "ELF") && strings.Contains(fo, "executable") {
|
||||
// fileType = fileTypeELFEXECUTABLE
|
||||
// } else if strings.Contains(fo, "Mach-O") && strings.Contains(fo, "executable") {
|
||||
// fileType = fileTypeMACHEXECUTABLE
|
||||
// } else if strings.Contains(fo, "ELF") && strings.Contains(fo, "shared") {
|
||||
// fileType = fileTypeELFSHARED
|
||||
// } else if strings.Contains(fo, "Mach-O") && strings.Contains(fo, "dynamically linked shared") {
|
||||
// fileType = fileTypeMACHSHARED
|
||||
// } else if strings.Contains(fo, "current ar archive") {
|
||||
// fileType = fileTypeARCHIVE
|
||||
// } else if strings.Contains(fo, "thin archive") {
|
||||
// fileType = fileTypeTHINARCHIVE
|
||||
// } else if strings.Contains(fo, "ELF") && strings.Contains(fo, "relocatable") {
|
||||
// fileType = fileTypeELFOBJECT
|
||||
// } else if strings.Contains(fo, "Mach-O") && strings.Contains(fo, "object") {
|
||||
// fileType = fileTypeMACHOBJECT
|
||||
// } else {
|
||||
// fileType = fileTypeUNDEFINED
|
||||
// }
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user