-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSymbolicSoftLink.cpp
More file actions
74 lines (61 loc) · 1.91 KB
/
Copy pathSymbolicSoftLink.cpp
File metadata and controls
74 lines (61 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// C/C++ program to create an Soft Link
// to the existing file
/// Only command line arguments work
/// Only command line arguments work
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <iostream>
#include <string>
#include <windows.h>
#include <cstdio>
using namespace std;
// Driver Code
int main(int argc, char* argv[])
{
char str[1000];
char str2[1000];
char* pstr = str;
char* pstr2 = str2;
const char* target = pstr;
const char* linked = pstr2;
int sl2;
// Symlink function
int sl = symlink(argv[1], argv[2]);
// argv[1] is existing file name
// argv[2] is soft link file name
if (sl == 0) {
printf("Soft Link created"
" succuessfuly");
}
else{
// string target, linked;
//
// puts("Please Enter an Existing file to be linked");
// cin>>target;
// puts("Please Enter an file to be created as soft link");
// cin>>linked;
puts("Please Enter an Existing file name with absolute path file to be linked");
fgets( pstr,1000, stdin );
cout<<"You entered"<<pstr<<endl;
puts("Please Enter an file name with absolute path to be created as soft link");
fgets( pstr2,1000, stdin );
cout<<"You entered"<<pstr2<<endl;
int sl2 = symlink(target, linked);
}
if (sl2 == 0) {
printf("Soft Link created"
" successfully");
}
return 0;
}
/// https://cboard.cprogramming.com/c-programming/102188-getting-const-char*-input.html
/// https://www.geeksforgeeks.org/taking-string-input-space-c-3-different-methods/
/// C:/Users/User/Desktop/ExistingSymSoftlink
/// "C:\Users\User\Desktop\ExistingSymSoftlink\222.txt"
/// "C:\Users\User\Desktop\ExistingSymSoftlink22\333222.txt"
/// Only command line arguments work
/// Only command line arguments work
/// "C:\Users\shyed\OneDrive\Desktop\SoftLink\111.txt"
/// "C:\Users\shyed\OneDrive\Desktop\SymLink\444.txt"