blob: d58275944c563357101df90b22fb772e0c16bbd1 [file] [log] [blame]
Reid Spencerb89a2232004-08-25 06:20:07 +00001//===-- Path.cpp - Implement OS Path Concept --------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file was developed by Reid Spencer and is distributed under the
6// University of Illinois Open Source License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This header file implements the operating system Path concept.
11//
12//===----------------------------------------------------------------------===//
Reid Spencer8e665952004-08-29 05:24:01 +000013
Reid Spencerb89a2232004-08-25 06:20:07 +000014#include "llvm/System/Path.h"
15
16namespace llvm {
Reid Spencer8e665952004-08-29 05:24:01 +000017using namespace sys;
Reid Spencerb89a2232004-08-25 06:20:07 +000018
19//===----------------------------------------------------------------------===//
20//=== WARNING: Implementation here must contain only TRULY operating system
21//=== independent code.
22//===----------------------------------------------------------------------===//
23
Reid Spencerf37ce992004-11-14 22:05:32 +000024LLVMFileType
25IdentifyFileType(const char*magic, unsigned length) {
26 assert(magic && "Invalid magic number string");
27 assert(length >=4 && "Invalid magic number length");
28 switch (magic[0]) {
29 case 'l':
30 if (magic[1] == 'l' && magic[2] == 'v') {
31 if (magic[3] == 'c')
32 return CompressedBytecodeFileType;
33 else if (magic[3] == 'm')
34 return BytecodeFileType;
35 }
36 break;
37
38 case '!':
39 if (length >= 8) {
40 if (memcmp(magic,"!<arch>\n",8) == 0)
41 return ArchiveFileType;
42 }
43 break;
44
45 default:
46 break;
47 }
48 return UnknownFileType;
49}
50
Reid Spencerb89a2232004-08-25 06:20:07 +000051}
52
53// Include the truly platform-specific parts of this class.
54#include "platform/Path.cpp"
Reid Spencerb89a2232004-08-25 06:20:07 +000055
Reid Spencer36853b92004-08-29 19:24:53 +000056// vim: sw=2 smartindent smarttab tw=80 autoindent expandtab